c++ - Create a vector as a function call parameter -


i have no idea have in situation..

class build_using_vector : public {  private:          int thing;          vector<int> list_elem;  public:          build_using_vector(int tthing, vector<int> llist_elem); }; 

ok not prob... second part still not prob:

build_using_vector::build_using_vector(int tthing, vector<int> llist_elem) : another()   {     thing = tthing;     list_elem = llist_elem;  } 

as said not prob.

the prob there, in "main". in case not "main" class... think same...

int main()  {    build_using_vector foo(5, ???) // don't know how build multiple of element example 5,6,7)    return 0;  } 

thank you

you can use list initilization. build_using_vector foo(5, ???) be

build_using_vector foo(5, {5,6,7}) 

i suggest use member initialization constructor , change

build_using_vector::build_using_vector(int tthing, vector<int> llist_elem) : another()  {     thing = tthing;     list_elem = llist_elem; } 

to

build_using_vector::build_using_vector(int tthing, vector<int> llist_elem) : another() , thing(tthing), list_elem(llist_elem) {} 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -