我有以下代码:
struct elements
{
char status;
int value;
};
class matrix
{
vector<vector <elements> > mat;
int varNum;
int ConNum;
public:
void resetmatrix(int varnum, int connum)
{
varNum = varnum;
ConNum = connum;
mat.resize(connum, vector<elements>(varnum) );
}
matrix(int x, int y)
{
varNum = 0;
ConNum = 0;
}
};
matrix mat(0,0);
int main(int argc, char *argv[]) //main function
{
int variables,cubes;
variables=25;
cubes= 10000000;
cout<<"Variables= "<<variables<<endl<<"Cubes= "<<cubes<<endl;
mat.resetmatrix(variables, cubes);
cout<<"hello";
return 0;
}
我收到以下错误
我认为只有当您没有调整矢量大小时才会出现此类错误。但我正在调整它。谁能告诉我为什么会这样?是因为立方体的价值非常高(1000万)?