行と列の数を取り、オブジェクト「セル」のデフォルト値でベクトルのベクトルを初期化し、そのベクトルへのポインターを返す関数があります。
//Cell class
class cell{
public:
int cost, parent;
cell(int cost = 0, int parent = 0) : cost(cost), parent(parent){}
}
//The initialisation function
vector<vector<cell> >* init_table(int n_rows, int n_cols){
//Error line
vector<vector<cell> >* table = new vector<vector<cell>(n_cols)> (n_rows);
//Some(very few) special cells need a different value so I do that here
return table; //Return the pointer
}
コンパイラは (n_cols)> (n_rows) を > 操作のように解決し、セル オブジェクトの n_cols コピーとベクトル オブジェクトの n_rows コピーを作成しないようです。ベクター内のデフォルト値のセルを手動でループしてプッシュせずにベクターを初期化するにはどうすればよいですか?