This question already has an answer here:
- How do I pass multiple ints into a vector at once? 5 answers
I was wondering if it is possible to push_back multiple elements to c++ vector more easily
For example
I create 5 objects
A a1;
A a2;
A a3;
A a4;
A a5;
Currently, i push all of them back like this
vector<A> list;
list.push_back(a1);
list.push_back(a2);
list.push_back(a3);
list.push_back(a4);
list.push_back(a5);
I was wondering if this can be done more succinctly like vector list(a1, a2, a3, a4, a5)..etc Thanks!