C++ complex numbers, what is the right format?

user2649077 picture user2649077 · Aug 3, 2013 · Viewed 32k times · Source

I want to use C++ with complex numbers. Therefore I included #include <complex>. Now my question is: How do I declare a variable?(so what is the format called for let's say: 1 + i?)

Thanks in advance :-)

Answer

Antti Haapala picture Antti Haapala · Aug 3, 2013
// 1 + 2i
std::complex<double> c(1, 2);