non-static data member initializers only available with -std=c++11 or -std=gnu++11
[enabled by default]
int Red = 255;
non-static data member initializers only available with -std=c++11 or -std=gnu++11
[enabled by default]
int Green = 255;
non-static data member initializers only available with -std=c++11 or -std=gnu++11
[enabled by default]
int Blue = 255;
不知道为什么这行不通。
struct color {
int Red = 255;
int Green = 255;
int Blue = 255;
};
最佳答案
启用c ++ 11或:
struct Color
{
int Red;
int Green;
int Blue;
Color() : Red(255), Green(255), Blue(255) {}
};
关于c++ - 非静态数据成员初始化器c++,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26350524/