非静态数据成员初始化程序c ++

use*_*600 0 c++ non-static data-members c++11

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;
Run Code Online (Sandbox Code Playgroud)

不知道为什么这不起作用.

struct color {
    int Red = 255;
    int Green = 255;
    int Blue = 255;
};
Run Code Online (Sandbox Code Playgroud)

mar*_*rsh 5

启用c ++ 11或:

struct Color
{
    int Red;
    int Green;
    int Blue;
    Color() : Red(255), Green(255), Blue(255) {}
};
Run Code Online (Sandbox Code Playgroud)