dimanche 19 avril 2015

How can I make a pointer to a member of a struct?


Vote count:

0





struct Color {
enum Color_type : unsigned char {
red=FL_RED,
blue=FL_BLUE,
green=FL_GREEN,
yellow=FL_YELLOW,
white=FL_WHITE,
black=FL_BLACK,
magenta=FL_MAGENTA,
cyan=FL_CYAN,
dark_red=FL_DARK_RED,
dark_green=FL_DARK_GREEN,
dark_yellow=FL_DARK_YELLOW,
dark_blue=FL_DARK_BLUE,
dark_magenta=FL_DARK_MAGENTA,
dark_cyan=FL_DARK_CYAN
};

enum Transparency : unsigned char { invisible = 0, visible=255 };

Color(Color_type cc) :v(visible), c(Fl_Color(cc)) { }
Color(Color_type cc, Transparency vv) :v(vv), c(Fl_Color(cc)) { }
Color(int cc) :v(visible), c(Fl_Color(cc)) { }
Color(Transparency vv) :v(vv), c(Fl_Color()) { } // default color

int as_int() const { return c; }

char visibility() const { return v; }
void set_visibility(Transparency vv) { v=vv; }
private:
unsigned char v; // invisible and visible for now
Fl_Color c;
};


I want to make a global pointer to the values of "FL_RED" and "FL_BLUE" or "Color::red" etc. What would the type be and how would I actually point to it?



asked 31 secs ago







How can I make a pointer to a member of a struct?

Aucun commentaire:

Enregistrer un commentaire