Share via


DECLARE_SERIAL

DECLARE_SERIAL generates the C++ header code necessary for a CObject-derived class that can be serialized. Serialization is the process of writing or reading the contents of an object to and from a file.

DECLARE_SERIAL(
class_name )

Parameters

  • class_name
    The actual name of the class (not enclosed in quotation marks).

Remarks

Use the DECLARE_SERIAL macro in a .H module, then include that module in all .CPP modules that need access to objects of this class.

If DECLARE_SERIAL is included in the class declaration, then IMPLEMENT_SERIAL must be included in the class implementation.

The DECLARE_SERIAL macro includes all the functionality of DECLARE_DYNAMIC and DECLARE_DYNCREATE.

You can use the AFX_API macro to automatically export the CArchive extraction operator for classes that use the DECLARE_SERIAL and IMPLEMENT_SERIAL macros. Bracket the class declarations (located in the .H file) with the following code:

#undef AFX_API
#define AFX_API AFX_EXT_CLASS

<your class declarations here>

#undef AFX_API
#define AFX_API

Example

class CMyClass: public CObject
{
public:
   CMyClass();
   void Serialize( CArchive& archive );

   DECLARE_SERIAL(CMyClass)
};

Requirements

**  Windows CE versions:** 2.0 and later
  Header file: Declared in Afx.h
  Platform: H/PC Pro, Palms-size PC, Pocket PC

See Also

IMPLEMENT_SERIAL, RUNTIME_CLASS