Jump to content
  • Advertisement
Sign in to follow this  
DOrmisher

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

This topic is 3681 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
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.

Share this post


Link to post
Share on other sites
As jpetrie said I think you are running something like Cyclick inclusion either directly or indirectly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!