我有以下内容:
#include <vector>
#include <complex>
using namespace std;
vector<vector<complex> > matrix;
这是一个具有复数值的二维 vector 。编译时不知道结构的大小,所以我认为 vector 是一个合理的选择?
我正在使用 Qt.. 搜索没有显示任何矩阵类。我应该使用替代方案吗?假设 2D vector 是一个不错的选择。为什么在构建时会发生这种情况:
我收到以下错误:
error: type/value mismatch at argument 1 in template parameter list for
'template<class _Tp, class _Alloc> class std::vector'
error: expected a type, got 'complex'
非常感谢。
最佳答案
complex
是一个模板类,因此您需要对其进行特化。我猜你想要 float
或 double
:
vector<vector<complex<double> > > matrix;
关于c++ - 二维复值 vector 初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13781696/