Hi I am trying to create a pointer to a vector of vectors of int, that is to achieve an effect similar to 2-d arrays. I use the following initialization –
vector< vector<int> >* v = new vector< <vector<int> >(10, vector<int>(5, 1));
However, gcc complains-
$ c++ test.cpp
test.cpp: In member function `int MonochromaticBoard::theMin(std::vector<std::string, std::allocator<std::string> >)':
test.cpp:14: error: template argument 1 is invalid
test.cpp:14: error: template argument 2 is invalid
However, this works –
vector< vector<int> > v(10, vector<int>(5, 1));
I tried searching on the web but couldn’t find an answer[1], any idea whats wrong in the first syntax?
[1] I found that someone at http://www.dreamincode.net/forums/topic/170469-pointer-to-vector-of-vectors/ was successful in initializing like that, but not sure.
Looks like you just have a typo – one too many <‘s after new vector: