Ich muss auf ein bestimmtes Element eines Vektors komplexer Daten in C++ zugreifen. HierFehler bei der Verwendung von komplexen Vektor
ist, was ich habe:
vector< complex<float> > x; // Create vector of complex numbers
x.push_back(complex<float>(1, 2)); // Place 1 + j2 in vector
x.push_back(complex<float>(2, 1)); // Place 2 + j1 in vector
// Attempt at accessing the zero-th elements real part
float temp1 = x.at(0).real;
float temp2 = x[0].real;
Dies gibt den folgenden Fehler in Visual Studio 2015:
Severity Code Beschreibung Projektdatei Zeilenunterdrückungszustand Fehler C3867 ‚std :: _ Complex_base: : real ': nicht standardisierte Syntax; Verwendung '&' ein Zeiger auf ein Element opencv_dft c zu erstellen: \ users \ josh \ VS_project \ main.cpp 101
Verwenden Sie 'x [0] .real()' oder noch besser 'mit std :: real; ... real (x [0]) '. – alfC