c++ - How to initialize a vector of a class type in a constructor -
i have class
class effeid { public: effeid(int a=0,int b=0,int c=0,int d=0):first(a),second(b),third(c),fourh(d){}; int first; int second; int third; int fourh; };
and second class
class axeeffect { public: //and want initialize constructor in way: axeeffect(int=0,string="",int=0,int=0,int=0,int=0,vector<effeid>??? );
how initialize part vector 0?
to create default argument vector<t>
construct one, else.
class foo { public: foo(const vector<int> &v = vector<int>()) : _v(v) {} private: vector<int> _v; };
also, wouldn't take vector
value. take reference avoid unnecessary copy.
Comments
Post a Comment