C++ Vector of vectors
- by xbonez
I have a class header file called Grid.h that contains the following 2 private data object:
vector<int> column;
vector<vector<int>> row;
And a public method whose prototype in Grid.h is such:
int getElement (unsigned int& col, unsigned int& row);
The definition of above mentioned function is defined as such in Grid.cpp:
int getElement (unsigned int& col, unsigned int& row)
{
return row[row][col] ;
}
When I run the program, I get this error:
error C2109: subscript requires array or pointer type
Whats going wrong?