[Univ of Cambridge] [Dept of Engineering]
next up previous contents
Next: Overriding behaviour Up: Classes Previous: Const members

Static Const members

Details regarding how to initialise static const members changed late in the C++ specification. A static const data member of integral or enum type can be initialized in the class definition, but you still need to provide another definition (without an initializer) for it. So
class C {
  const static int csi = 5;
};

const int C::csi;
is legal, but you can't do the same for floats, non-statics or non-consts. With some old compilers you have to initialise outside the class.



Tim Love
2001-07-05