[英]vector initialization in vs2010
#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? 可以在c9中编译代码,但在vs2010中,无法成功编译。为什么?
MS VC ++ 2010不支持将std::initializer_list
作为标准容器的成员函数的参数。
You may follow this, 您可以遵循此,
static const string arrStr[] = {"abc", "abc", "abc", "abc", "abc"};
vector<string> s(arrStr, arrStr + sizeof(arrStr)/sizeof(arrStr[0]));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.