Board index » Visual Studio » CObject 'class' type redefinition

CObject 'class' type redefinition

Visual Studio251
Hi,

I couldn't figure out the errors and I've checked the MSDN. The error I've

got is

error C2011: 'CObject': 'class' type redefinition



CObject was defined in Object.h

CObject.cpp includes CObject.h



And in the view class (MFC) as well

hence CMyView.h

when I comment out CMyView.h, it compiles okay

but I need access to CObject.h because I need to define several CObject

Objects... What else can I do?



//////////////////////////////////////////////////////// CObject.h

#ifndef _OBJECT_H_

#define _OBJECT_H_



class CObject

{

protected:

CPerformer* m_pMA;

DWORD m_dwMultiAnimIdx;

CMesh* m_pAI;

vector<CObject *>*m_pv_pChars;

CSoundManager* m_pSM;

//////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////// CObject.cpp

#include "dxstdafx.h"

#include "AllocHierarchy.h"

#include "DSUtil.h"

#include "Object.h"



CObject::CObject()

{

}



CObject::~CObject()

{

Cleanup();

}



void CObject::Cleanup()

{

}

/////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////CMyView.h

#include "dxstdafx.h"

#include "dsutil.h"

#include "AllocHierarchy.h"

#include "Object.h"

#include <queue>



class CMFCSimV6Build1View : public CView, public CD3DApplication

{

protected:

CMyView();

DECLARE_DYNCREATE(CMyView)





public:

CMyDoc* GetDocument() const;

protected:

HINSTANCE m_hInstance;



LPD3DXMESH m_pMeshFloor;

D3DXMATRIX m_mxFloor;

D3DMATERIAL9 m_MatFloor;

LPDIRECT3DTEXTURE9 m_pTxFloor;



ID3DXFont* m_pFont;

CFirstPersonCamera m_Camera;

float m_fAspectRatio;

CSoundManager m_DSound;



CPerformer m_Lorry; // inherit from CObject



vector< CLorry*>m_v_pLorry; // have definition in the CObject

class where CLorry is derived from CObject

////////////////////////////////////////////////////////////////////////////////





Thanks

Jack


-
 

Re:CObject 'class' type redefinition



"Jack" <jl@knight.com>¼¶¼g©ó¶l¥ó·s»D:OJ87dPu3FHA.2872@TK2MSFTNGP15.phx.gbl...

Quote
Hi,

I couldn't figure out the errors and I've checked the MSDN. The error I've

got is

error C2011: 'CObject': 'class' type redefinition



CObject was defined in Object.h

CObject.cpp includes CObject.h



And in the view class (MFC) as well

hence CMyView.h

when I comment out CMyView.h, it compiles okay

No. Sorry, should be "comment out CObject.h"





Quote
but I need access to CObject.h because I need to define several CObject

Objects... What else can I do?



//////////////////////////////////////////////////////// CObject.h

#ifndef _OBJECT_H_

#define _OBJECT_H_



class CObject

{

protected:

CPerformer* m_pMA;

DWORD m_dwMultiAnimIdx;

CMesh* m_pAI;

vector<CObject *>*m_pv_pChars;

CSoundManager* m_pSM;

//////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////// CObject.cpp

#include "dxstdafx.h"

#include "AllocHierarchy.h"

#include "DSUtil.h"

#include "Object.h"



CObject::CObject()

{

}



CObject::~CObject()

{

Cleanup();

}



void CObject::Cleanup()

{

}

/////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////CMyView.h

#include "dxstdafx.h"

#include "dsutil.h"

#include "AllocHierarchy.h"

#include "Object.h"

#include <queue>



class CMFCSimV6Build1View : public CView, public CD3DApplication

{

protected:

CMyView();

DECLARE_DYNCREATE(CMyView)





public:

CMyDoc* GetDocument() const;

protected:

HINSTANCE m_hInstance;



LPD3DXMESH m_pMeshFloor;

D3DXMATRIX m_mxFloor;

D3DMATERIAL9 m_MatFloor;

LPDIRECT3DTEXTURE9 m_pTxFloor;



ID3DXFont* m_pFont;

CFirstPersonCamera m_Camera;

float m_fAspectRatio;

CSoundManager m_DSound;



CPerformer m_Lorry; // inherit from CObject



vector< CLorry*>m_v_pLorry; // have definition in the CObject

class where CLorry is derived from CObject

////////////////////////////////////////////////////////////////////////////////





Thanks

Jack











-

Re:CObject 'class' type redefinition



"Jack" <jl@knight.com>¼¶¼g©ó¶l¥ó·s»D:OJ87dPu3FHA.2872@TK2MSFTNGP15.phx.gbl...

Quote
Hi,

I couldn't figure out the errors and I've checked the MSDN. The error I've

got is

error C2011: 'CObject': 'class' type redefinition



CObject was defined in Object.h

CObject.cpp includes CObject.h



And in the view class (MFC) as well

hence CMyView.h

when I comment out CMyView.h, it compiles okay

but I need access to CObject.h because I need to define several CObject

Objects... What else can I do?



//////////////////////////////////////////////////////// CObject.h

#ifndef _OBJECT_H_

#define _OBJECT_H_



class CObject

{

protected:

CPerformer* m_pMA;

DWORD m_dwMultiAnimIdx;

CMesh* m_pAI;

vector<CObject *>*m_pv_pChars;

don't worry about this, I have commented this out too





Quote
CSoundManager* m_pSM;

//////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////// CObject.cpp

#include "dxstdafx.h"

#include "AllocHierarchy.h"

#include "DSUtil.h"

#include "Object.h"



CObject::CObject()

{

}



CObject::~CObject()

{

Cleanup();

}



void CObject::Cleanup()

{

}

/////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////CMyView.h

#include "dxstdafx.h"

#include "dsutil.h"

#include "AllocHierarchy.h"

#include "Object.h"

#include <queue>



class CMFCSimV6Build1View : public CView, public CD3DApplication

{

protected:

CMyView();

DECLARE_DYNCREATE(CMyView)





public:

CMyDoc* GetDocument() const;

protected:

HINSTANCE m_hInstance;



LPD3DXMESH m_pMeshFloor;

D3DXMATRIX m_mxFloor;

D3DMATERIAL9 m_MatFloor;

LPDIRECT3DTEXTURE9 m_pTxFloor;



ID3DXFont* m_pFont;

CFirstPersonCamera m_Camera;

float m_fAspectRatio;

CSoundManager m_DSound;



CPerformer m_Lorry; // inherit from CObject



vector< CLorry*>m_v_pLorry; // have definition in the CObject

class where CLorry is derived from CObject

////////////////////////////////////////////////////////////////////////////////





Thanks

Jack











-

Re:CObject 'class' type redefinition

Jack wrote:

Quote
>I couldn't figure out the errors and I've checked the MSDN. The error I've

>got is

>error C2011: 'CObject': 'class' type redefinition



Change your class name. CObject is an MFC class.



--

Scott McPhillips [VC++ MVP]



-

Re:CObject 'class' type redefinition

Oh yeah, got it. Thanks

Jack



"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>

???????:ucbQkou3FHA.3460@TK2MSFTNGP12.phx.gbl...

Quote
Jack wrote:

>>I couldn't figure out the errors and I've checked the MSDN. The error

>>I've got is

>>error C2011: 'CObject': 'class' type redefinition



Change your class name. CObject is an MFC class.



--

Scott McPhillips [VC++ MVP]







-