[Solved] How to create a vector of complex numbers in c++? [closed]


Here’s an example I used:

double real;
double imaginary;
std::vector<std::complex<double> > database;
//...
std::cin >> real;
std::cin >> imaginary;
const std::complex<double> temp(real, imaginary);
database.push_back(temp);

In the above example, I read in the real and imaginary components separately. Next, I create a temporary complex object using the real and imaginary components. Finally, I push_back the value to the database.

solved How to create a vector of complex numbers in c++? [closed]