c++ - what's wrong with defining a 2d vector as a data member of a class in this way? -


i coding class has 2d vector in private data members named board, have defined vector in header file of class: world.h:

vector <vector<cell> > board; vector <cell> columns;//cell name of class 

world.cpp:

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

and after tried access members of vector in way:

board[i][j] 

i had errors said

error error c2065: 'board' : undeclared identifier

what's wrong it?


more of code added: world.h:

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

world.cpp:

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

i function doesn't know board! , have error because of this.

it because of forgetting of entering : using namespace std;


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -