我需要調整(未知大小的)的二維矢量,如下所示:如何動態調整二維矢量?
//Creating the vector of vectors:
vector< vector<long> > v;
//Resizing the vectors:
/*Needing help here:
my current assumption is:
v.resize(1);
v[0].resize(1);
*/
//Adding elements:
v[0][0].push_back(0);
v[0][1].push_back(-1);
在施加的push_back編譯器報告錯誤。我想我在調整矢量大小時遇到問題。
目標是創建一個二維向量,根據添加的值動態分配內存。
在此先感謝您的幫助
「你可能想把這整件事整理在課堂上來強化這種一致性。」請不要自己動手;使用'boost :: multi_array'。 – 2011-04-27 17:38:07
非常感謝!我認爲你的解決方案對我而言是最準確的解決方案。 – CompilingCyborg 2011-04-27 18:11:46