Apr 18, 2012 at 6:13pm UTC
Hi,
I'm trying to declare a vector of strings but it doesn't seem to be working.
vector<string> colourMenu ("Red" , "Orange" , "Yellow" , "Green" , "Blue" , "Purple" );
This should work shouldn't it?
instead I'm having to do this:
1 2 3 4 5 6 7
vector<string> colourMenu;
colourMenu.push_back("Red" );
colourMenu.push_back("Orange" );
colourMenu.push_back("Yellow" );
colourMenu.push_back("Green" );
colourMenu.push_back("Blue" );
colourMenu.push_back("Purple" );
Is what I'm doing already the only way of doing it?
Last edited on Apr 18, 2012 at 6:15pm UTC
Apr 18, 2012 at 6:21pm UTC
You need to use a recent compiler and enable C++11 support if necessary.
Even then, the correct syntax is:
vector<string> colourMenu {"Red" , "Orange" , "Yellow" , "Green" , "Blue" , "Purple" };