Possible Duplicate:
C++: Easiest way to initialize an STL vector with hardcoded elements
How to initialize a vector in c++
I was wondering if there's a way to make a vector with announced elements..
Instead of having to do:
vector< int > v;
v.push_back(3);
v.push_back(5);
v.push_back(1);
and etc, where v = {3,5,1}
,
I want to make a vector that already contains elements like:
vector< int > v = {3,5,1};
Because it is a lot of work inserting each number in the vector. Is there a shortcut to this?