M
marcus
I have a class which has one static data member.
The .h file containing this class is included from many cpp files.
Therefor I have the definition part of the data member in the
implementation of the class (in the .cpp file) to avoid getting
"multiple defined..." error. In the .cpp file I put the definition
outside any method.
In the .h file:
class ....
{
private:
static GeometryDataLL *allMeshes;
}
In the .cpp file
GeometryDataLL* scGeometry::allMeshes = (GeometryDataLL*) calloc (1,
sizeof(GeometryDataLL));
On Windows ME on my laptop, this works fine (the data member allMeshes
is allocated before the constructor is run), but on my stationary
computer which has Windows XP, I get a crash in the constructor of the
..cpp file, because the allocation has not been done.
Why is this, and how can I avoid this.
thanks
Marcus
The .h file containing this class is included from many cpp files.
Therefor I have the definition part of the data member in the
implementation of the class (in the .cpp file) to avoid getting
"multiple defined..." error. In the .cpp file I put the definition
outside any method.
In the .h file:
class ....
{
private:
static GeometryDataLL *allMeshes;
}
In the .cpp file
GeometryDataLL* scGeometry::allMeshes = (GeometryDataLL*) calloc (1,
sizeof(GeometryDataLL));
On Windows ME on my laptop, this works fine (the data member allMeshes
is allocated before the constructor is run), but on my stationary
computer which has Windows XP, I get a crash in the constructor of the
..cpp file, because the allocation has not been done.
Why is this, and how can I avoid this.
thanks
Marcus