saving problem using serializion in C++
-
I'm writing a project and in that project I have a class named user_info that represent information about users. I have another class named user_list, that represent a list of users, and use CObLis. The information that I place in the list I want to save on disk, so i use for that serialization. The problem is that when I want to save the information, than the program crash. This is the header of user_info: #include // replace with #define _CONSOLE when compiling for Windows NT #define _DOS #include class user_info : public CObject { DECLARE_SERIAL(user_info) public: user_info(); user_info(CString suser_name,CString spassword,int suser_id,CString sname,CString sfamily_name,int suser_type,int scity_id,int sarea_id,int sonline=0); virtual ~user_info(); // user_info() {} user_info( const user_info &s ) // copy ctor { user_name = s.user_name; password = s.password; user_id = s.user_id; family_name = s.family_name; user_type = s.user_type; city_id = s.city_id; area_id = s.area_id; online = s.online; } user_info& operator=( const user_info &s ) // assignment operator { user_name = s.user_name; password = s.password; user_id = s.user_id; family_name = s.family_name; user_type = s.user_type; city_id = s.city_id; area_id = s.area_id; online = s.online; return *this; } CString get_user_name(); CString get_password(); int get_user_id(); CString get_name(); CString get_family_name(); int get_user_type(); int get_city_id(); int get_area_id(); int get_statuse(); void test_list(); void Serialize (CArchive& ar); private: CString user_name; CString password; int user_id; CString name; CString family_name; int user_type; int city_id; int area_id; int online; }; This is the implication of the Serialize method in the user_indo.cpp file: IMPLEMENT_SERIAL(user_info, CObject, 0) void user_info::Serialize(CArchive& ar) { CObject::Serialize (ar); if (ar.IsStoring()) ar << user_name << password << user_id << name << family_name << user_type << city_id << area_id << online; else ar >> user_name >> password >> user_id >> name >> family_name >> user_type >> city_id >> area_id >> online; } This is the implication of the constructor of user_list: user_list::user_list() { char* FileName="user_list.dat"; user_list::numOfUsers =0; if (users_file.Open (FileName, CFile::modeRead)) { CAr