Sign in to follow this  
Antonym

Undefined base class?

Recommended Posts

I get this error 1>c:\documents and settings\david\mis documentos\visual studio 2005\projects\dungeon\dungeon\asteroid.h(13) : error C2504: 'Object' : base class undefined with the following code, I have no idea what's causing it, what does this sort of error refer to?
#ifndef ASTEROID_H
#define ASTEROID_H

enum asteroid_type{SMALL, MEDIUM, LARGE};

#include <d3d9.h>
#include <d3dx9.h>
#include "Object.h"
#include "Application.h"
#include "Game.h"

class Asteroid: public Object
{
private:
	float rotate_amount;
	asteroid_type asteroid_size;

public:
	Asteroid(D3DXVECTOR2, 
			 float, 
			 Application&,
			 std::string,
			 int,
			 int,
			 int, 
			 int,
			 int,
			 float,
			 asteroid_type);

	void update(Game&);
	void handle_collision(Game&, Object&);
	void handle_death(Game&);

};

#endif

Object class
#ifndef OBJECT_H
#define OBJECT_H

class Object;

#include <d3d9.h>
#include <d3dx9.h>
#include "SpriteInstance.h"
#include "Game.h"
#include <vector>

enum object_type{SHIP, MISSILE, ASTEROID, EFFECT};

class Object
{
private:
	D3DXVECTOR2 position;
	float rotation;
	SpriteInstance sprite_instance;
	D3DXVECTOR2 velocity;
	int radius;
	int mass;
	DWORD time_since_last_shot;
	DWORD cooldown;
	int impact_damage;
	int hit_points;
	bool hit_animation;
	float speed;
	object_type type;

public:
	//Constructors
	Object(D3DXVECTOR2, //position 
		   float, //rotation
		   Sprite*, //sprite
		   int, //size
		   int, //radius
		   int, //mass
		   int, //impact_damage
		   int, //hit points
		   float, //speed,
		   object_type); //object_type

	//Position
	D3DXVECTOR2 get_position();
	void move();

	//Rotation
	float get_rotation();
	void rotate(float);

	//Sprite Instance
	SpriteInstance get_sprite_instance();

	//Velocity
	void update_velocity();
	D3DXVECTOR2 get_velocity();

	//Cooldown
	void set_time_since_last_shot(DWORD);
	DWORD get_time_since_last_shot();
	DWORD get_cooldown();

	//Collision
	void collision_check(Game&, std::vector<Object*>&);
	void check_collision(Game&, Object&);
	virtual void handle_collision(Game&, Object&) =0;

	//Damage
	void damage(int);
	void check_death(Game&);
	virtual void handle_death(Game&) =0;
	void play_death(Game&);
	int get_impact_damage();

	//Hit Animation
	void play_hit(Game&);
	void set_hit_animation(bool);
	bool get_hit_animation();

	//Speed
	void change_speed(float);
	float get_speed();

	//Type
	object_type get_object_type();

	//Extra
	virtual void update(Game&) =0;
	float degrees_to_radians(float);

};

#endif

Share this post


Link to post
Share on other sites
Well I don't use a master header, I had heard before it could cause trouble. Although I think it did have something to with that. The game class included asteroid class and vice versa. Found a solution though, I moved the enum back to the game.h so that I could remove the asteroid include. I was wondering where should enums go in a project?

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