Tos*_*hko 3 c++ struct warnings g++ c++11
#include <iostream>
using namespace std;
struct test
{
int factorX;
double coefficient;
};
int main()
{
test firstTest = {1, 7.5}; //that's ok
test *secondTest = new test;
*secondTest = {8, 55.2}; // issue a compiler warning
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么编译器发出以下警告:
test2.cpp:13:33: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
test2.cpp:13:33: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
Run Code Online (Sandbox Code Playgroud)
我知道在C++ 11中我可以省略赋值运算符,但事实并非如此.我正在使用g ++ 4.7.2.