【发布时间】:2011-08-25 08:13:47
【问题描述】:
我在向量中嵌套向量时遇到问题,相当于 C 中的 2D 数组。我已经尝试了在众多网站上发布的代码,但无济于事。
class Board
{
public:
vector< vector<Cell> > boardVect; //Decalre the parent vector as a memebr of the Board class
Board()
{
boardVect(3, vector<Cell>(3)); //Populate the vector with 3 sets of cell vectors, which contain 3 cells each, effectivly creating a 3x3 grid.
}
};
当我尝试编译时,我收到此错误:
F:\main.cpp|52|error: no match for call to '(std::vector >) (int, std::vector)'
第 52 行是:boardVect(3, vector<Cell>(3));
是我在用 3 个向量类构造父向量时遇到错误吗?
【问题讨论】:
标签: c++ class vector nested-class