#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
}
我不明白为什么编译器会发出以下警告:
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]
我知道在 C++11 中我可以省略赋值运算符,但事实并非如此。我正在使用 g++ 4.7.2。