Reputation: 103
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
class M {
vector<string> s;
public:
M(){
s = {"abc", "abc", "abc", "abc", "abc"};
}
};
int main(){
return 0;
}
The code can be compiled in c9, but in vs2010, it can't be compiled successfully.why?
Upvotes: 1
Views: 1731
Reputation: 320
You may follow this,
static const string arrStr[] = {"abc", "abc", "abc", "abc", "abc"};
vector<string> s(arrStr, arrStr + sizeof(arrStr)/sizeof(arrStr[0]));
Upvotes: 1
Reputation: 310980
MS VC++ 2010 does not support std::initializer_list
as a parameter for member functions of standard containers.
Upvotes: 3