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