clist

MFC serialization

大兔子大兔子 提交于 2019-12-23 03:49:09
问题 i have to serialize a CList of base and derived classes. How can i do that. typedef CList<Student*, Student*> StVec; class Student : public CObject { public: DECLARE_SERIAL(Student); Student(); Student(Student& s); Student(CString _name, CString _last, int _age); virtual ~Student(void); virtual void cin(); virtual void cout(); virtual void Serialize(CArchive& ar); static Student* FromInput(); inline const CString GetName(){return name;} inline const CString GetLastName(){return last_name;}

Does MFC CList support the copy assignment?

醉酒当歌 提交于 2019-12-12 17:12:55
问题 I've looked up the CList definition in MSVC afxtempl.h and document on MSDN. I did not see the CList& operator=(const CList&); is defined. Can I directly use operator= to copy a CList object like this? CList<int> a = b; Or I should iterate the source CList manually from head to tail and AddTail on the target CList? for(POSITION pos = a.HeadPosition(); pos; ) { const auto& item = a.GetNext(pos); b.AddTail(item); } Any suggestions will be helpful. Thanks. 回答1: If the copy assignment operator