mfc向导默认建好的文档类源代码中只有DECLARE_DYNCREATE和IMPLEMENT_DYNCREATE宏,没有DECLARE_SERIAL和IMPLEMENT_SERIAL宏,怎么也能实现串行化,串行化到底需要使用哪个宏

解决方案 »

  1.   

    你需要好好看一下MSDN上的这一段:
    Serialization: Making a Serializable Class
    Five main steps are required to make a class serializable. They are listed below and explained in the following sections: 1. Deriving your class from CObject (or from some class derived from CObject). 2. Overriding the Serialize member function. 3. Using the DECLARE_SERIAL macro in the class declaration. 4. Defining a constructor that takes no arguments. 5. Using the IMPLEMENT_SERIAL macro in the implementation file for your class. If you call Serialize directly rather than through the >> and << operators of CArchive, the last three steps are not required for serialization. 
    // 注意看这里有一段话
      

  2.   

    存盘的时候直接调用文档类的serialize函数就不需要那些宏了,多谢了