Assuming that there is a Class called Solution:
class Solution{
private:
int COL;
int ROW;
vector<vector <int>> grid(ROW, vector<int>(COL));
public:
void setData();
};
Then put the definition of function setData()
void Solution::setData(){
for (int i = 0; i < ROW; i++){
for (int j = 0; j < COL; j++){
grid[i][j] = 1;
}
}
}
- Firstly, in the declaration of vector
grid
,ROW
andCOL
is unread; - Secondly, if I revise the declaration of
grid
asvector<vector<int>> grid(100, vector<int>(100))
(namely, define dimension of vector clearly), it then lose the feature of dynamic - Last, if I revise the declaration of vector
grid
, the programme would be interrupted when runningsetData()
Sincerely thank you for any suggestions!
thanks for you guys, I defined the constructor function:
Solution(){
ROW = 100;
COL = 100;
}
however, COL and ROW is also unreadable in definition of grid
(vector<vector>)
thank you!