我有这样的结构初始化用户的矢量的矢量定义
struct myStruct {
int a;
int b;
}
我想创建一个vector <vector<myStruct> > V
并将其初始化类型的n
空载体vector<myStruct>
我试图使用在fill constructor 这样的:
vector<edge> temp;
vector<vector<edge> > V(n, temp);
此代码工作正常main
,但是当我在一个类里面有V
时,我该如何在类构造函数中做到这一点。
编辑: 当我在我的类的构造函数,我得到以下错误:
no match for call to '(std::vector<std::vector<edge> >) (int&, std::vector<edge>&)'
代码生成的错误是:
vector<myStruct> temp;
V(n, temp); // n is a parameter for the constructor
使用初始化程序列表。 – Kunal