Hi Peter, as for the static const declarations - there should (must) be a definition for each static const member of a class, but if it is an int or an enum data type some compilers (for example gcc do this) can perform optimisation and insert the static const value right into the code without needed to have it in memory. There could be some problems though, like if you want to get address of that variable or use some more complex object types in there.
For example you can try this piece of code:
struct A
{
static const int I = 10;
};
int main()
{
const int *i = &A::I;
return 0;
}
You should get “undefined reference to `A::I’” message from linker. So that is why I’m providing extra definition for all static const class variables. I hope I didn’t say something that make no sense and it’s clear now :). I think that the same result is in the article you gave me link to.
Petr
