Infamous Vtable error (in my books)

I am now getting a vtable error for my enemy class in my rpg game. It says undefined refernce to 'Vtable for Enemy' . I'm thinking its my constructor that is going wrong with the Enemy class. I've tried almost everything but kept getting stumped on a problem. Here is my enemy.cpp class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "Enemy.h"

Enemy::Enemy(int EnemyHealth,int EnemyMana)
{
    Attackpower;
    Strenght;
    Enemyxp;

}

Enemy::~Enemy()
{
    //dtor
}


Enemy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef ENEMY_H
#define ENEMY_H


 class Enemy
{
public:
    Enemy(int EnemyHealth,int EnemyMana);
    ~Enemy();
      virtual void TheenemyHealth(){}
     virtual int EnemyDamage(int EnemyAttack){
int  Attack = EnemyAttack;
     }
virtual int dropxp(int enemyxpdrop);



private:
  int Attackpower= 0;
  int Strenght = 0;
  int Enemyxp= 0;

};


#endif // ENEMY_H 

My inhertiance class Monster.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef MONSTER_H
#define MONSTER_H
#include "Enemy.h"



class Monster : public Enemy
{
    Monster();

Monster(int MonsterHealth, int MonsterMana,int Monstersize,int Monsterenemymana);
    void TheenemyHealth()
    {
        int Enemyhealth = 100;
    }
    int EnemyDamage(int EnemyAttack){
    int Attack = EnemyAttack;
    Attack = 5;
    }
    int dropxp(int enemyxpdrop);
    private:
   int Health = 0;
   int Mana = 0;
};

#endif // MONSTER_H 

Monster.cpp
1
2
3
4
5
6
7
8
9
10
11
12
#include "Monster.h"
#include "Enemy.h"
#include <iostream>
Monster::Monster(int MonsterHealth,int MonsterMana,int Monstersize,int Monsterenemymana) // implementation
 : Health(MonsterHealth), Mana(MonsterMana), Enemy(Monstersize,Monsterenemymana) {}


int Monster::dropxp(int enemydropxp){


}

So the probelem lies within the constructors ,but I don't know which one and why. I don't mind you changing up my entire code I love improvements towards everything I do.
Last edited on
You did not define all declared functions.
https://gcc.gnu.org/faq.html#vtables
At the bottom.
Last edited on
Please show me where MiiNiPaa I haven't declared all functions
You're not defining Enemy::dropxp(int enemydropxp); :)
also you may want to look up abstract classes! It'll probably fit your situation a little better but you be the judge.
Topic archived. No new replies allowed.