* Susan Baker:
I got this error msg whilst building some classes. It is realatively asy
to fix. But I just wondered, does anyone know the technical reason why
one can't initialiaze a const static non-integral data member in a class?
No.
But apparently, from earlier discussions, adding support for that would
have opened a can'o'worms, other related issues to be considered.
The support that is there, for integral type constants, allows those
constants to be used as template arguments and as array size specifiers.
A double (say) constant cannot be used that way. So it seems the
committee chose to add only the minimal support absolutely required for
the most common compile time usage.
Btw., "relatively easy to fix", in the sense of finding some
work-around, isn't necessarily true, because C++ doesn't support
'inline' for constants, i.e. you cannot just use the keyword 'inline' to
make a constant definition have external linkage in a way so the that
the linker is happy with multiple definitions.
One workaround for that is to use templating, and that makes the
restriction very difficult to understand: the templating work-around
shows that it would not entail anything extra in compiler and linker
machinery to support 'inline' for this purpose.