I wish to create a vector of MyClass, like the following Course class. and I wish to pass an array of string as the names of Courses. So I write
struct Course {
int id;
string name;
static int id_generator;
Course() {}
Course(string s);
};
Course::Course(string s) {
name = s;
id = id_generator++;
}
int Course::id_generator = 0;
This works
string course_names[] = {"Linux", "C++", "HTML", "HTML5", "NodeJS", "Shell", "Python"};
vector<Course> course_vector(begin(course_names), end(course_names));
but this doesn't
vector<Course> course_vector = {"Linux", "C++", "HTML", "HTML5", "NodeJS", "Shell", "Python"};
error: could not convert ‘{"Linux", "C++", "HTML", "HTML5", "NodeJS", "Shell", "Python"}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<Course>’
why? how to do better?