Inner or nested classes
-
GURU's only!:eek: I have a class "hidden" inside my main class, a kind of inner class if U like.
class a : public CObject { DECLARE_DYNCREATE(a) public: a(); class b : public CObject { DECLARE_DYNCREATE(b) public: b(); }; };
But the IMPLEMENT_DYNAMIC macro expansion baffles the compiller's brainIMPLEMENT_DYNCREATE(a, CObject) IMPLEMENT_DYNCREATE(b, CObject)
with the following messages: error C2653: 'b' : is not a class or namespace name error C2061: syntax error : identifier 'b' I have tried everything but write my own body for CreateObject() so I can get runtime class info, doingIMPLEMENT_DYNCREATE(a::b, CObject)
Seems logical, but does not hel, since a is nit a namespace or so the compiller says.:( Conrad - conradb@adroit.co.za Always do badly to start off, that way when you get the hang of it suddenly, everyone is surprised. -
GURU's only!:eek: I have a class "hidden" inside my main class, a kind of inner class if U like.
class a : public CObject { DECLARE_DYNCREATE(a) public: a(); class b : public CObject { DECLARE_DYNCREATE(b) public: b(); }; };
But the IMPLEMENT_DYNAMIC macro expansion baffles the compiller's brainIMPLEMENT_DYNCREATE(a, CObject) IMPLEMENT_DYNCREATE(b, CObject)
with the following messages: error C2653: 'b' : is not a class or namespace name error C2061: syntax error : identifier 'b' I have tried everything but write my own body for CreateObject() so I can get runtime class info, doingIMPLEMENT_DYNCREATE(a::b, CObject)
Seems logical, but does not hel, since a is nit a namespace or so the compiller says.:( Conrad - conradb@adroit.co.za Always do badly to start off, that way when you get the hang of it suddenly, everyone is surprised.X| I have since tried.....
typedef a::b NestedBase; IMPLEMENT_DYNCREATE(a, CObject) //from #define RUNTIME_CLASS(class_name) ((CRuntimeClass*)(&class_name::class##class_name)) #define MYRUNTIME_CLASS(class_name) ((CRuntimeClass*)&a::b::b()) // from _IMPLEMENT_RUNTIMECLASS #ifdef _AFXDLL #define MY_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \ CRuntimeClass* PASCAL class_name::_GetBaseClass() \ { return RUNTIME_CLASS(base_class_name); } \ CRuntimeClass* class_name::GetRuntimeClass() const \ { return MYRUNTIME_CLASS(class_name); } // AFX_COMDAT AFX_DATADEF CRuntimeClass class_name::class##class_name = { \ // #class_name, sizeof(class class_name), wSchema, pfnNew, \ // &class_name::_GetBaseClass, NULL }; #else #define MY_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \ CRuntimeClass* PASCAL class_name::_GetBaseClass() \ { return RUNTIME_CLASS(base_class_name); } \ CRuntimeClass* class_name::GetRuntimeClass() const \ { return MYRUNTIME_CLASS(class_name); } #endif // from IMPLEMENT_DYNCREATE, just calls MY_IMPLEMENT_RUNTIMECLASS instead #define MYIMPLEMENT_DYNCREATE(class_name, base_class_name) \ CObject* PASCAL class_name::CreateObject() \ { return new class_name; } \ MY_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \ class_name::CreateObject) MYIMPLEMENT_DYNCREATE(NestedBase, CObject)
... but to no avail, since I cannot get the last bit of my MY_IMPLEMENT_RUNTIMECLASS macro to work (commented out) hELP hELP HeLP HElp. Conrad - conradb@adroit.co.za Always do badly to start off, that way when you get the hang of it suddenly, everyone is surprised.