Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Inner or nested classes

Inner or nested classes

Scheduled Pinned Locked Moved C / C++ / MFC
help
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    conrad Braam
    wrote on last edited by
    #1

    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 brain IMPLEMENT_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, doing IMPLEMENT_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.

    C 1 Reply Last reply
    0
    • C conrad Braam

      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 brain IMPLEMENT_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, doing IMPLEMENT_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.

      C Offline
      C Offline
      conrad Braam
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups