MFC Serialization
-
I have a class structure as follows: Class A: public CObject { } Class B: Public A { } Now I want to serialize pointer class B using CArchive. How can this be done? Regards
-
I have a class structure as follows: Class A: public CObject { } Class B: Public A { } Now I want to serialize pointer class B using CArchive. How can this be done? Regards
in .h file
class A : public CObject
{
public:
DECLARE_SERIAL( A )
// empty constructor is necessary
A(){};void Serialize( CArchive& archive );
};
in .cpp file
IMPLEMENT_SERIAL( A, CObject, 1 )
void A::Serialize( CArchive& archive )
{
// call base class function first
// base class is CObject in this case
CObject::Serialize( archive );// now do the stuff for our specific class if( archive.IsStoring() ) ///serialize it else //deserialise it
}
Hope this code help you , for further reading MSDN has good explanation for serialization.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time. 2.Why do people ask for time from people who are not wearing a wrist watch. Prakash, India.