error C2504: 'CEntityTemplate' : base class undefined - BUT IT IS!

Started by
1 comment, last by nlbs 15 years, 5 months ago
Hi, compiler throwing up the error:
error C2504: 'CEntityTemplate' : base class undefined
This is the code that is producing the error:

#pragma once
#include "Defines.h"
#include "Entity.h"
#include "ShaderManager.h"

class CTankTemplate : public CEntityTemplate
{
public:
	CTankTemplate( const string& Type, const string& Name, const string& Filename, //These 2 lines get the rendering
				   ERenderMethod RenderMethod, CShaderManager* shaderManager,	   //and mesh info.
				   float MaxSpeed, float Acceleration, float TurnSpeed,			   //These set the variables for driving mechanics
				   int Weight, int MaxHealth, LPDIRECT3DDEVICE9 d3dDevice );
...and also later on in the header...

class CTankEntity : public CEntity
{
public:
	CTankEntity( CEntityTemplate* Template, string Name,
				 float posX=0.0f, float posY=0.0f, float posZ=0.0f, 
				 float rotX=0.0f, float rotY=0.0f, float rotZ=0.0f, 
				 float scaleX=1.0f, float scaleY=1.0f, float scaleZ=1.0f );
As you can see I have included the header "Entity.h" and this is where both base classes are defined! I have tried using forward declaration at the top of the file, but this just throws up the same error. Even stranger is if I define the base classes at the tope of the file like so...
class CEntity{};
class CEntityTemplate{};
...it then throws up an error saying CEntity and CEntityTemplate have been already been defined and sends you to the .cpp file with the definitions of the two classes in!! Any help would be appreciated.
She got a hat and all that hat says is asshole
Advertisement
Are you running into this? The names of your header files and your error messages correlate to this kind of problem.

Without seeing the full code of the translation unit in which the error occurs and the code of every it's hard to say for sure, but its entirely possible the ordering of your headers is such that you are producing a translation unit with the base class defined after the derived, and thus the compiler emits the error you're seeing.
As jpetrie said I think you are running something like Cyclick inclusion either directly or indirectly.

This topic is closed to new replies.

Advertisement