hello,
I am trying to initialize the size of a 2 dimensional vector with this way:
running the code with root it I get these errors:
expected parameter declarator vector<vector> mat(10, vector);
expected ')'
to match this '( ’ vector<vector> mat(10, vector);
also if i compile and run the code i get this:
expected primary-expression before ‘)’ token
why? Which is the correct way to do it?
std::vector<std::vector > mat(10, std::vector()); // allocate 10 x 0
std::vector<std::vector > mat(10, std::vector(20)); // allocate 10 x 20
both gave me exactly the same errors as before…
yes, of course!
In my code this vector is defined inside a structure. I just realise that if I define it outside of the structure the problem disappears…
but why?
finally it needs a constructor to work
[code]struct aa{
vector<vector > a;
aa() :
a(10, vector<int>(10))
{}
};[/code]