我有一个叫做“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