Static const variable is not constant in child class
问题 I am using Visual Studio 2008 and have two classes Parent and Child. Parent declares some static const variables in the header, which are then defined in the cpp file. When I try to use the defines as cases in a switch statement in a child class I get the error: C2051: case expression not constant . So I've done some testing and the behavior I'm seeing is somewhat inconsistent. // Parent.h class Parent { public: Parent(); ~Parent(void) { } static const unsigned long A = 1; static const