class GamePlayer {
private:
static const int NumTurns = 5;
int scores[NumTurns];
...
};
order compilers may not accept the syntax above, because it used to be illegal to provide an initial value for a static class member at its point of declaration. Furthermore, in-class initialization is allowed only for integral types and only for constants.
class GamePlayer {
private:
enum { NumTurns = 5 };
int scores[NumTurns];
...
};
but it is not legal to take the address of an enum or a #defines
because #define do not respect scope. Which means that not only can not #defines be used for class-specific constants, they also can not be used to provide any kind of encapsulation.