Firstly, I'd like to apologise if this is a blinding simple and obvious question. I know it's a fairly easy one to people with the know-how. C++11 allows vectors to be initialised in list form:
std::vector<std::string> v = {
"this is a",
"list of strings",
"which are going",
"to be stored",
"in a vector"};
But this isn't available in older versions. I've been trying to think of the best way to populate a vector of strings and so far the only thing I can really come up with is:
std::string s1("this is a");
std::string s2("list of strings");
std::string s3("which are going");
std::string s4("to be stored");
std::string s5("in a vector");
std::vector<std::string> v;
v.push_back(s1);
v.push_back(s2);
v.push_back(s3);
v.push_back(s4);
v.push_back(s5);
It works, but it's a bit of a chore to write and I'm convinced there's a better way.