使用complex
类和库,如何将复数分配给变量?
我知道我可以在第一次实例化复数时设置该值。
我也明白我可以将一个实例化的复数分配给另一个。
如何直接将复数分配给变量?
参考:
http ://www.cplusplus.com/reference/complex/complex/operators/
例子:
#include <iostream>
#include <complex>
int main() {
complex<double> a(1.2,3.4), b;
cout << a; //-> (1.2,3.4)
b = a;
cout << b; //-> (1.2,3.4)
b = (1.2,3.4);
cout << b; //-> (3.4,0) <-- what the heck is this??
return 0;
}