我有一個叫做「tileManager」的對象,我想做一些讓我可以用[0] [1] [0] [2] ..... [1] [0]等將數組插入向量中<vector<int>>
裏面的那個對象我有一個std::vector<std::vector<int> >
爲了得到一個多維向量。
這是目前我的代碼,我想知道如何插入的陣列成多維向量
代碼:
void tileManager::initTileVec() {
int checkWidth = 0;
int checkHeight = 0;
int row = 0;
int column = 0;
int pixels = (GetSystemMetrics(SM_CXSCREEN) - GetSystemMetrics(SM_CYSCREEN))/3;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
tileVec[column][row] = [checkHeight , checkWidth];
row += 1;
}
column += 1;
}
}
你不能。類型必須匹配。在'vector>'中使用'std :: pair ',否則使用類型,直到它們匹配。 –
AndyG
我也建議你看看[逗號運算符](http://en.cppreference.com/w/c/language/operator_other#Comma_operator)。因爲'tileVec [column,row]'可能不會像你期望的那樣工作(我認爲)。 –
是啊是的,我只是修復它,並把它變成tileVec [專欄] [行]我的壞 – greuzr