I want to use C++ with complex numbers. Therefore I included #include . Now my question is: How do I declare a variable?(so what is the format ca
You define a variable by specifying a template parameter and specifying a name for the variable, about like with most other templates:
std::complex x(1, 1);
The first parameter to the ctor is the real part, the second the imaginary part.
Starting with C++ 14, a user-defined literal operator has been added, so you can initialize a complex variable with a somewhat more natural notation:
using namespace std::literals;
std::complex c = 1.2 + 3.4i;
In this case, (obviously enough) the 1.2 is the real part and the 3.4 is the imaginary part.