Sign in to follow this  

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

This topic is 3321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this