问题描述
我不知道为什么我遇到错误
“警告:扩展的初始化程序列表仅在-std = c ++ 11或-std = gnu ++ 11 [默认启用]下可用”
class file
{
private:
string* arr;
public:
void list();
}
在.cpp文件中
void file::list()
{
arr = new string[2]{"1","2"};
}
解决方法
我不知道为什么我遇到错误
warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
之所以收到警告,是因为在上下文中使用了初始化列表,直到C ++ 11才允许使用它,并且您没有使用C ++ 11或更高版本。因此,程序格式错误,需要编译器向您显示一条消息。