serializing classes in MFC 
Author Message
 serializing classes in MFC

Please help...

I have a problem with serializing my own classes derived from CObject:

(I'm using MS Visual C++ v5.0 with MFC v4.2)

I Created a dummy class (see file listings below) and tried to link them to
a framework MFC application created with AppWizard.
----------------------------------------------------------------------------
---------------
// MyClass.h
// CMyClass class definition
//
#include "stdafx.h"

class CMyClass : public CObject {

        DECLARE_SERIAL(CMyClass)

// member variables
private:
        WORD m_n1;

//Constructor and destructor
        CMyClass();

public:
        void Serialize (CArchive &ar);

Quote:
};

----------------------------------------------------------------------------
---------------

//MyClass.cpp
//CMyClass implementation file
//
#include "MyClass.h"

IMPLEMENT_SERIAL(CMyClass, CObject, 1)

CMyClass::CMyClass()
{
        m_n1 = 1; //

Quote:
}

void CMyClass::Serialize (CArchive &ar)
{
        CObject::Serialize(ar);

        if (ar.IsStoring())
                ar << m_n1;
        else
ar >> m_n1;

Quote:
}

----------------------------------------------------------------------------
---------------

I keep getting the following message when I try to build and execute...

"MyClass.cpp(31) : fatal error C1010: unexpected end of file while looking
for precompiled header directive. Error executing cl.exe."

... can anybody explain the reason for this and suggest a solution?

Thanks in advance



Sat, 16 Sep 2000 03:00:00 GMT  
 serializing classes in MFC

'#include "stdafx.h"' belongs in myclass.cpp, not myclass.h and this
message belongs in microsoft.public.vc.mfc, not
microsoft.public.vc.database.



Quote:
>Please help...

>I have a problem with serializing my own classes derived from CObject:

>(I'm using MS Visual C++ v5.0 with MFC v4.2)

>I Created a dummy class (see file listings below) and tried to link them to
>a framework MFC application created with AppWizard.
>----------------------------------------------------------------------------
>---------------
>// MyClass.h
>// CMyClass class definition
>//
>#include "stdafx.h"

>class CMyClass : public CObject {

>    DECLARE_SERIAL(CMyClass)

>// member variables
>private:
>    WORD m_n1;

>//Constructor and destructor
>    CMyClass();

>public:
>    void Serialize (CArchive &ar);

>};
>----------------------------------------------------------------------------
>---------------

>//MyClass.cpp
>//CMyClass implementation file
>//
>#include "MyClass.h"

>IMPLEMENT_SERIAL(CMyClass, CObject, 1)

>CMyClass::CMyClass()
>{
>    m_n1 = 1; //

>}

>void CMyClass::Serialize (CArchive &ar)
>{
>    CObject::Serialize(ar);

>    if (ar.IsStoring())
>            ar << m_n1;
>    else
>ar >> m_n1;
>}
>----------------------------------------------------------------------------
>---------------

>I keep getting the following message when I try to build and execute...

>"MyClass.cpp(31) : fatal error C1010: unexpected end of file while looking
>for precompiled header directive. Error executing cl.exe."

>... can anybody explain the reason for this and suggest a solution?

>Thanks in advance


Don Grasberger
(remove --- from address to e-mail)


Sun, 17 Sep 2000 03:00:00 GMT  
 serializing classes in MFC

Put #include "stdafx.h" in your cpp file not your .h file

Quote:

>Please help...

>I have a problem with serializing my own classes derived from CObject:

>(I'm using MS Visual C++ v5.0 with MFC v4.2)

>I Created a dummy class (see file listings below) and tried to link them to
>a framework MFC application created with AppWizard.
>---------------------------------------------------------------------------
-
>---------------
>// MyClass.h
>// CMyClass class definition
>//
>#include "stdafx.h"

>class CMyClass : public CObject {

> DECLARE_SERIAL(CMyClass)

>// member variables
>private:
> WORD m_n1;

>//Constructor and destructor
> CMyClass();

>public:
> void Serialize (CArchive &ar);

>};
>---------------------------------------------------------------------------
-
>---------------

>//MyClass.cpp
>//CMyClass implementation file
>//
>#include "MyClass.h"

>IMPLEMENT_SERIAL(CMyClass, CObject, 1)

>CMyClass::CMyClass()
>{
> m_n1 = 1; //

>}

>void CMyClass::Serialize (CArchive &ar)
>{
> CObject::Serialize(ar);

> if (ar.IsStoring())
> ar << m_n1;
> else
>ar >> m_n1;
>}
>---------------------------------------------------------------------------
-
>---------------

>I keep getting the following message when I try to build and execute...

>"MyClass.cpp(31) : fatal error C1010: unexpected end of file while looking
>for precompiled header directive. Error executing cl.exe."

>... can anybody explain the reason for this and suggest a solution?

>Thanks in advance




Tue, 19 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. serializing classes in MFC

2. serializing classes in MFC

3. Problem with STL string class and MFC Serialize()

4. Serializing STL template classes with MFC

5. serializing a class derived from an abstract base class

6. Serialize class derived from virtual base class

7. Creating a DLL in MFC to store a class not derived from an MFC class

8. Serializing: How to guarantee that I can de-serialize a serialized class in a year?

9. Serializing a class hierarchy

10. Problem serializing Classes with Delegates and events

11. SOAP serializing classes

12. Serializing a class inherited from DataSet

 

 
Powered by phpBB® Forum Software