I have to write something like
q.push_back(q1); ... to ... q.push_back(q100);
I am writing this as
for (int i = 1; i <= 100; i++) {
try {
std::string s = boost::lexical_cast<std::string > (i);
"q.push_back(q" + s + ");";
} catch (boost::bad_lexical_cast &) {
std::cout << "Some error message \n";
}
}
It compiles (no syntax errors) but does not work. I don't know how to mix cpp statements and strings to make a compound statement.
Any help here would be highly appreciated. Thanks!
q1, q2, q3, ... q100and you want to put them into one vector, right?"q.push_back(q" + s + ");";what did you expect this string literal to do?