static const Member Value vs. Member enum : Which Method is Better & Why?
If you want to associate some constant value with a class, here are two ways to accomplish the same goal: class Foo { public: static const size_t Life = 42; }; class Bar { public: enum {Life = 42}; }; Syntactically and semantically they appear to be identical from the client's point of view: size_t fooLife = Foo::Life; size_t barLife = Bar::Life; Is there any reason other than just pure style concerns why one would be preferable to another? The enum hack used to be necessary because many compilers didn't support in-place initialization of the value. Since this is no longer an issue, go for the