This snippet is based on an example I took from a C++ book.
The author wants to illustrate how to realize a simple enumeration without enumeration (it's a preliminary example, before the chapter about enumeration).
I can't understand why this snippet compiles without problem.
1) Here, we have a function that should return a ColourLight Type, but it returns an int type:
1 2 3
ColourLight value() const {
return val;
}
2) What kind of inizialization is that?
1 2 3 4
const ColourLight red = 0;
const ColourLight redYellow = 1;
const ColourLight yellow = 2;
const ColourLight green = 3;