MrB*_*ach 1 c++ struct vector header-files
我在下面有这个结构用于矩阵.当我在main.cpp中声明它时,它已经正常工作,但由于程序变得更复杂,我决定将其交换掉.所以我的头文件看起来像这样:
#ifndef MATRIX_STRUCT_H
#define MATRIX_STRUCT_H
#include <vector>
// Matrix datatype
struct matrix_ {
// Matrix dimension m x n
unsigned int dimX; // n
unsigned int dimY; // m
bool square;
// Matrix coefficients
vector <vector <double>> coef;
};
typedef struct matrix_ matrix;
#endif // MATRIX_STRUCT_H
Run Code Online (Sandbox Code Playgroud)
我现在遇到的问题是,第4行#include <vector>如果不在这里就没有区别.我总是得到第13行的错误
error: 'vector' does not name a type
Run Code Online (Sandbox Code Playgroud)
如果你想知道我为什么使用结构而不是类,我只是最近刚从C来到,所以我还没有任何类的经验.
请问有人可以帮助我吗?放弃结构并专注于课程会更好(有帮助)吗?