"Scott J. McCaughrin" <sj******@bluestem.prairienet.org> wrote in message
news:cm**********@wildfire-pl.prairienet.org...
The following short program compiles fine but fails to link (both on
Borland C++ and GNU g++). In particular, g++ gives this link error:
"undefined reference to `VarArrar::funct'".
It seems as if the static data-member (of type Funct) is regarded as
an external, hence unresolvable by 'ld'. If so, why is a static member
considered an extern, and what is the remedy?
If it were not then every source file in which you included the class
definition would get a separate definition of the static data member,
resulting in multiple definition errors.
The remedy is the same as with globals, define the static data member in one
source file
Funct SomeClass::some_member = something;
john