我需要访问C++中复杂数据矢量的特定元素。使用复杂矢量的错误
以下是我有:
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;
这给在Visual Studio 2015年以下错误:
严重性代码说明项目文件的线路抑制状态 错误C3867“的std :: _ Complex_base: :真实':非标准语法;使用 '&' 创建一个指向成员opencv_dft C:\用户\乔希\ VS_project \ main.cpp中101
使用'x [0] .real()'或甚至更好'使用std :: real; ... real(x [0])'。 – alfC