#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。
@Toshko:很高興幫助:) – 2013-03-20 13:08:14