感谢所有帮助,我已将初始化移至构造函数,但是,我在定义 2D 向量时遇到了困难:
这是我所做的:
private:
vector < vector <int> > Matrix;
vector < vector <int> > temp_m;
vector <int> elements
string input;
int value;
function()
{
//Initialize Both Matrices (one which holds the puzzle and the
//other which holds the values between 1 and 9
//Create a vector of vectors:
for(int i = 0; i < 9; i++)
elements.push_back(i+1);
for(int i = 0; i < 9; i++)
Matrix[i].push_back(elements); //ERROR HERE
}
我在定义 2D 矩阵的行中遇到错误。我想将矩阵推回其索引,因为它是矩阵的矩阵。