How can I create an NxM 2D int vector and create default values for it?
Here I try to create a 3x3 int vector with some values:
vector< vector<int> > m(3, vector<int> (3)) = {
{1,2,9},
{8,4,7},
{5,6,0}
};
But this errors with
> g++ a.cpp -std=c++11
error: expected ‘,’ or ‘;’ before ‘=’ token
vector< vector<int> > m(3, vector<int> (3)) = {
^
error: expected ‘}’ at end of input
}
I am using c++11 also, so shouldn't the above syntax be correct? According to this answer, it should be okay?