C++ examples for Data Type:complex
Three Techniques for Creating a complex Number
#include <iostream> #include <complex> using namespace std; complex<long double> operator"" _i(long double Value) { return complex<double>(0, Value); } int main() /*from w w w . ja v a 2s . c o m*/ { complex<double> StdComplex(0, 3.14); auto AutoComplex = 3.14_i; auto UDLComplex = 3.14i; cout << StdComplex.real() << " " << StdComplex.imag() << endl; cout << AutoComplex.real() << " " << AutoComplex.imag() << endl; cout << UDLComplex.real() << " " << UDLComplex.imag() << endl; return 0; }