I am trying to serialize a class. Some of the data they have to be stored are contained in a CList. I have tried to serialize the class following the common way with no luck so far. I have also tried to use pointers to CList but even that didn't work. Can anyone help me on that? the code i use look like that:
// h file
class CMemberData : public CObject
{
DECLARE_SERIAL( CMemberData )
protected:
CList<myMEMBER, myMEMBER&>* Members;
public:
CMemberData();
~CMemberData();
virtual void Serialize( CArchive& ar );
};
// ccp file
IMPLEMENT_SERIAL(CMemberData,CObject,1)
CMemberData::CMemberData() : Members(NULL)
{
Members = new CList<myMEMBER, myMEMBER&>;
}
CMemberData::~CMemberData()
{
if (Members) delete Members;
}
void CMemberData::Serialize(CArchive& ar)
{
CObject::Serialize( ar );
if (ar.IsStoring())
{
ar << Members;
}
else
{
ar >> Members;
}
}
many thanks in advance
// h file
class CMemberData : public CObject
{
DECLARE_SERIAL( CMemberData )
protected:
CList<myMEMBER, myMEMBER&>* Members;
public:
CMemberData();
~CMemberData();
virtual void Serialize( CArchive& ar );
};
// ccp file
IMPLEMENT_SERIAL(CMemberData,CObject,1)
CMemberData::CMemberData() : Members(NULL)
{
Members = new CList<myMEMBER, myMEMBER&>;
}
CMemberData::~CMemberData()
{
if (Members) delete Members;
}
void CMemberData::Serialize(CArchive& ar)
{
CObject::Serialize( ar );
if (ar.IsStoring())
{
ar << Members;
}
else
{
ar >> Members;
}
}
many thanks in advance