#include <vector>
...
//inside main function
vector<int> vi3 = {42,42,42,42,42,42,42,42,42,42};
I'm learning C++, I thought it was possible to initialize a vector like this... Am I doing something wrong? I know about the other ways of initializing a vector. In the book I'm reading it says it can also be done like this:
vector<int> vi3{42,42,42,42,42,42,42,42,42,42};
It's the first thing on the book that gave me an error. What am I doing wrong?
It's not clear which compiler you are using, but versions of Microsoft's Visual Studio before the 2013 preview do not support the uniform initialisation syntax {}
If you are using gcc you need to tell it to use C++11:
-std=c++0x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With