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. Serialization question...

Serialization question...

Scheduled Pinned Locked Moved C / C++ / MFC
questionjsonhelptutorial
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.
  • W Offline
    W Offline
    work_to_live
    wrote on last edited by
    #1

    I have a class with members that are pointers to the base class of derived classes... Here's a simplified example. class CDerivedClass : public CBaseClass { DECLARE_SERIAL(CDerivedClass) int something; } class CBaseClass : public CObject { DECLARE_SERIAL(CBaseClass) ... void Serialize(CArchive &ar); ... (data to archive) } class CCompoundClass : public CObject { DECLARE_SERIAL(CCompountClass) ... void Serialize(CArchive &ar); ... CBaseClass *ptrBaseClass; // points to the CDerivedClass } I dynamically allocate CDerivedClass, and set the CBaseClass pointer in the CCompoundClass to this object. I want to make the CCompoundClass Serializable, but don't seem to have the right recipe to pick up the derived class that ptrBaseClass points to. Any suggestions? I read through the help documentation, but it doesn't cover this case.

    W 1 Reply Last reply
    0
    • W work_to_live

      I have a class with members that are pointers to the base class of derived classes... Here's a simplified example. class CDerivedClass : public CBaseClass { DECLARE_SERIAL(CDerivedClass) int something; } class CBaseClass : public CObject { DECLARE_SERIAL(CBaseClass) ... void Serialize(CArchive &ar); ... (data to archive) } class CCompoundClass : public CObject { DECLARE_SERIAL(CCompountClass) ... void Serialize(CArchive &ar); ... CBaseClass *ptrBaseClass; // points to the CDerivedClass } I dynamically allocate CDerivedClass, and set the CBaseClass pointer in the CCompoundClass to this object. I want to make the CCompoundClass Serializable, but don't seem to have the right recipe to pick up the derived class that ptrBaseClass points to. Any suggestions? I read through the help documentation, but it doesn't cover this case.

      W Offline
      W Offline
      work_to_live
      wrote on last edited by
      #2

      I should have submitted this earlier... After scratching my head for a few hours, I deleted the object files (clean), rebuilt, and everything worked as expected. :)

      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