I have problem with my simple data base program in C++ (with inheritance and virtual func.) I've done class hirarchy which represents the object Weapon:
#ifndef Ammu_h
#define Ammu_h
#include <string>
#include <iostream>
using namespace std;
//////////HEADER FILE//////////////
class Weapon{
protected:
string name;
char damage;
public:
virtual void show() = 0;
//virtual ~Weapon();
};
class WhiteArm: public Weapon{
protected:
double sharpness;
double defence;
};
class Axe: public WhiteArm{
public:
Axe(string str, char dmg, double shrp, double def){
name = str;
damage = dmg;
sharpness = shrp;
defence = def;
};
void show(){
cout << this->name << this->damage << this->sharpness << this->defence << endl;
};
//class Sword: public WhiteArm{...};
//class Club: public WhiteArm{...};
};
#endif
First of all im not quite sure if my implementation is proper.
My main problem is that when I add a virtual destructor, I get error:
LNK2001: unresolved external symbol "public: __thiscall Weapon::~Weapon(void)"
I thought it is necessary to make the destructor virtual when the base class contains virtual methods.Is it good to make constructors at the end of hierarchy? (like me, upper)
I will appreciate every suggestion to my code Thanks in advance