Error C2248: cannot access private struct declared in class
Posted on 2006-10-27
I don't understand why the following code is not able to compile on Windows, I was able to compile it on redhat 3.0.
ClassFreeMem<ClassOne>* coneClass::freememory= 0;
InitFreeMemPtrs(void) // Default constructor.
// Allocate the freestore in the correct order.
ClassOne::ClassTwo::freememory= new ClassFreeMem<ClassOne::ClassTwo>; -> compile error here C2248
ClassOne::freememory= new ClassFreeMem<ClassOne>;
~InitFreeMemPtrs(void) // Default destructor.
// Delete the freestore in the correct order.
delete ClassOne::ClassTwo::freememory; -> compile error here C2248
static FlFreeStoreClass<ClassOne>* freememory;
static ClassFreeMem<ClassTwo>* freememory;
If I move the struct ClassTwo in the public area, then I am able to compile. At this point, I would like to find a better solution than moving the struct ClassTwo to public. Why this is able to compile on Linux, but not windows?
Looking foward to hear from you.