When I initialize a vector in C++ like this:
#include <string>
#include <vector>
using std::vector;
using std::string;
int main() {
vector<int> v1 = {1, 2, 3, 4};
return 0;
}
I got this error:
prog1.cpp:8:15: error: non-aggregate type 'vector<int>' cannot be initialized with an initializer list
vector<int> v1 = {1, 2, 3, 4};
^ ~~~~~~~~~~~~
1 error generated.
Any idea why this happens?