I'm stuck since many hours on an inheritance trouble and I need your light to unlock me...
My goal is to make a game, and I'm trying to create monsters.
error: ‘FastMob’ was not declared in this scope static_assert(std::is_base_of::value, "Mob is not a base class of FastMob");
FastMob inherit from Mob which inherit from Character, here is my .hh and .cpp
Mob.hh
#ifndef MOB_hh
#define MOB_hh
#include "Character.hh"
class Mob : public Character
{
private:
//position
double _x, _y;
int _life;
public:
Mob() {};
virtual ~Mob() = 0;
double GetX() const;
double GetY() const;
virtual int GetLife() const;
void SetX(double);
void SetY(double);
void SetLife(int);
void Draw()
{
Character::Draw();
}
void Update()
{
Character::Update();
}
};
#endif
FastMob.hh
#ifndef FASTMOB_HH
#define FASTMOB_HH
#include "Mob.hh"
class FastMob : public Mob
{
public:
FastMob();
~FastMob();
void Update() override;
};
#endif
FastMob.cpp
#include "FastMob.hh"
#include "Timer.hh"
FastMob::FastMob()
{
Mob::SetLife(25);
}
void FastMob::Update()
{
// some code
}
FastMob::~FastMob()
{}
Character.hh
#ifndef CHARACTER_hh
#define CHARACTER_hh
class Character
{
public:
Character() {};
virtual ~Character() = 0;
virtual void Update() = 0;
virtual void Draw() = 0;
};
#endif
Thanks !
Aucun commentaire:
Enregistrer un commentaire