当你在另一个类中使用它时,我如何确保我实现的 somecolor 保持他的价值?
结构体.h
struct Color{
unsigned char r;
unsigned char g;
unsigned char b;
};
Color someColor;
//if i define the color here it says...:
Color someColor = {255,255,255}; //error: data member inializer not allowed
结构体.cpp
struct::Color someColor = {255,255,255};
其他类.cpp
struct *str = new struct();
str->someColor.r //is not the correct value /not set