Sign in to follow this  
Sirisian

C++, undefined base class

Recommended Posts

Sirisian    2263
ok, this seems like an easy question. I've been looking at this code for 2 days and I just don't see it. Normally I can figure out a simple compiler error, but I can't see what's causing it. It seems like my base class is defined, but it says it isn't. So if you can take the time to help me I would appreciate it. gameobject_vehicle.hpp(14) : error C2504: 'MultiGameObject' : base class undefined okay just look at the code and see if you can find what's causing it. To help understand my object inheritance tree, just think GameObject -> MultiGameObject -> Vehicle GameObject.hpp
#ifndef GAME_OBJECT_HPP
#define GAME_OBJECT_HPP

#include "Vector2f.hpp"
#include "GameObjectBoundaryManager.hpp"

namespace Ancient
{

enum ObjectType;

class GameObject
{
  public:
	Vector2f pos;
	GameObject * ParentObject;

	virtual ~GameObject();

	virtual ObjectType GetType() = 0;
	virtual GameObject * Clone() = 0;

	virtual void Initialize();
	virtual Vector2f * GetPosition();
	virtual bool HasLocalQuadrant();
	virtual float GetQuadrantDimensionWidth();
	virtual float GetQuadrantDimensionHeight();
	virtual void SetBoundary(BoundaryBox * boundaryBox);
	virtual int GetRenderLayer();
	
};

}

#endif /* GAME_OBJECT_HPP */


GameObject.cpp
#include "GameObject.hpp"

namespace Ancient
{

GameObject::~GameObject(){}


bool GameObject::HasLocalQuadrant(){return false;}

void GameObject::Initialize(){}

Vector2f * GameObject::GetPosition(){return &pos;}

float GameObject::GetQuadrantDimensionWidth(){return 0;}

float GameObject::GetQuadrantDimensionHeight(){return 0;}

void GameObject::SetBoundary(BoundaryBox * boundaryBox){}

int GameObject::GetRenderLayer(){return 0;}

}


GameObject_MultiGameObject.hpp
#ifndef GAME_OBJECT_MULTI_GAME_OBJECT_HPP
#define GAME_OBJECT_MULTI_GAME_OBJECT_HPP

#include <vector>

#include "GameObject.hpp"
#include "ObjectFactory.hpp"

namespace Ancient
{

class GameObject;

class MultiGameObject : public GameObject
{
  public:
	std::vector<GameObject*> mObjects;

	virtual ~MultiGameObject();
	virtual ObjectType GetType();
	virtual GameObject * Clone();
};

}

#endif /* GAME_OBJECT_MULTI_GAME_OBJECT_HPP */


GameObject_MultiGameObject.cpp
#include "GameObject_MultiGameObject.hpp"

namespace Ancient
{

MultiGameObject::~MultiGameObject(){
	
}

ObjectType MultiGameObject::GetType(){
	return MULTIGAMEOBJECT;
}

GameObject * MultiGameObject::Clone(){
	GameObject * pNewObject = NULL;

	return pNewObject;
}

}


GameObject_Vehicle.hpp
#ifndef GAME_OBJECT_VEHICLE_HPP
#define GAME_OBJECT_VEHICLE_HPP

//#include "Vector2f.hpp"


#include "GameObject_MultiGameObject.hpp"
//#include "ObjectFactory.hpp"

namespace Ancient
{

class Vehicle : public MultiGameObject
{
  public:
	//Vector2f velocity;
	//Vector2f offsetView;

	Vehicle();

	ObjectType GetType();
	GameObject * Clone();
};

}

#endif /* GAME_OBJECT_VEHICLE_HPP */


GameObject_Vehicle.cpp
#include "GameObject_Vehicle.hpp"

#include "GameObject.hpp"

namespace Ancient
{

Vehicle::Vehicle(){

}

ObjectType Vehicle::GetType(){
	return VEHICLE;
}

GameObject * Vehicle::Clone(){
	GameObject * pNewObject = NULL;

	return pNewObject;
}

}


Those are the three classes. Is there anything else that can cause this kind of error? I am completely stuck. note: I'm fleshing out my classes so they might not make much sense, just trying to get the structure down.

Share this post


Link to post
Share on other sites
phil_t    8084
Where is the enum ObjectType defined? I see the declaration, but is that enough to allow the GameObject class to be defined?

Also, you don't need the class GameObject; fwd declaration in GameObject_MultiGameObject.hpp, since you're including GameObject.hpp (which you have to, since you're inheriting from GameObject).

Share this post


Link to post
Share on other sites
Sirisian    2263
The enum ObjectType is in the ObjectFactory.hpp. But I get what your saying, I'll try to see if that changes it. Thank you very much.

//edit, okay I have been messing with the enum and it's definitely the thing causing the error.

//edit, yah it works!

[Edited by - Sirisian on November 10, 2006 10:26:40 PM]

Share this post


Link to post
Share on other sites

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