Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不知道为什么我得到以下错误
“警告:扩展初始化列表仅适用于 -std=c++11 或 -std=gnu++11 [默认启用]”
我有 .h 和 .cpp 文件
在 .h 文件中,我声明了变量名
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]
warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
您收到警告是因为您在 C++11 之前不允许使用的上下文中使用了初始化列表,并且您没有使用 C++11 或更高版本。因此,程序格式错误,编译器需要向您显示消息。