使用complex对象

#include<iostream>
#include<string>
#include<complex>

using namespace std;
void main()
{
    complex <int> num1(3, 4);
    complex <float> num2(3.3, 4.5);
    string str1("real is ");
    string str2 = "imag is ";
    cout << str1 << num1.real() << "," <<str2<< num1.imag() << endl;
    cout << str1 << num2.real() << "," <<str2<< num2.imag() << endl;
}

运行结果:

 

end

posted @ 2016-03-21 22:34  知_行  阅读(683)  评论(0编辑  收藏  举报