Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. saving problem using serializion in C++

saving problem using serializion in C++

Scheduled Pinned Locked Moved Managed C++/CLI
c++jsonhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chen_k
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups