I was wondering if it is possible to have an array value in an enum? Example
enum RGB {
RED[3],
BLUE[3]
} color;
That way RED could contain values of (255,0,0) since that is the RGB color code for red.
No you can't do that with an enum. It looks a lot like you want a class/struct:
class Color {
public:
int red;
int green;
int blue;
Color(int r, int g, int b) : red(r), green(g), blue(b) { }
};
Once you have that class defined, you can then put it into a container (e.g. array, vector) and look them up. You could use an enum to refer to elements in an array, for example.
enum PresetColor {
PRESET_COLOR_RED,
PRESET_COLOR_GREEN,
PRESET_COLOR_BLUE,
};
...
Color presetColors[] = { Color(255, 0, 0), Color(0, 255, 0), Color(0, 0, 255) };
Color favouriteColor = presetColors[PRESET_COLOR_GREEN];
With that in mind, you could wrap all this up to be more maintainable, but I would say that's out of the scope of this question.
static const int enumValues[numColors][3]containing colors corresponding to enums. You still can doenum RGB { RED = 0xff000, BLUE=0x00ff00, ...}.