0

我正在编写一个在其名为 board 的私有数据成员中有一个二维向量的类,我在类的头文件中定义了这样的向量:World.h:

vector <vector<Cell> > board;
vector <Cell> columns;//Cell is name of another class

世界.cpp:

columns.resize(number_of_columns);
for(int i=0;i<number_of_lines;i++) board.push_back(number_of_columns);

在此之后,我尝试以这种方式访问​​向量的成员:

board[i][j]

我有错误说

错误错误 C2065:“板”:未声明的标识符

它出什么问题了?


添加了更多代码:World.h:

class World {
    private :
    bool ring;
    int lines, columns ;
    vector <Cell> columns;
        vector <vector<Cell> > board;
public:
    //blahhhh
    };

世界.cpp:

World:: World(int l , int c)
{
    columns.resize(c);
    for(int i=0;i<l;i++) board.push_back(columns);
}

我这个功能它不知道什么是板!并因此出现错误。

4

1 回答 1

0

这是因为忘记输入 : using namespace std;

于 2013-05-12T05:29:23.457 回答