I have this struct
struct myStruct {
int a;
int b;
}
I want to create a vector <vector<myStruct> > V
and initialize it to n
empty vectors of type vector<myStruct>
I'm trying to use the the fill constructor like this:
vector<edge> temp;
vector<vector<edge> > V(n, temp);
This code works fine in main
, but when I have V
inside a class how can I do that inside the class constructor.
EDIT:
when I do it in my class constructor I get the following error:
no match for call to '(std::vector<std::vector<edge> >) (int&, std::vector<edge>&)'
the code generating the error is:
vector<myStruct> temp;
V(n, temp); // n is a parameter for the constructor