I made this simple classes and I don't know why I'm keep getting error; here's my code:
using namespace std;
class Player{
public:
Player(string name);
virtual ~Player();
virtual void fight() = 0;
private:
string _name;
};
#include "Player.h"
#include <iostream>
using namespace std;
class Elf : public Player{
public:
Elf(string elf_name);
~Elf();
void fight(){
cout << "I kill you!" << endl;
}
private:
string _elf_name;
};
class Dwarf : public Player{
public:
Dwarf(string dwarf_name);
~Dwarf();
void fight(){
cout<< "Where's The Arkengem!?" << endl;
}
private:
string _dwarf_name;
};
Here's the main:
#include <iostream>
#include <vector>
#include "Player.h"
#include "Elf.h"
#include "Dwarf.h"
using namespace std;
int main(){
vector<Player*> playerGroup;
Elf* aElf = new Elf("Legolas");
Dwarf* aDwarf = new Dwarf("Gimli");
playerGroup.push_back(aElf);
playerGroup.push_back(aDwarf);
vector<Player*>::const_iterator itr;
for(itr = playerGroup.begin(); itr != playerGroup.end(); itr++){
cout << " " << *itr;
}
return 0;
}
That's the error message:
Undefined symbols for architecture x86_64:
"Elf::Elf(std::__1::basic_string, std::__1::allocator >)", referenced from: _main in Principale.o
"Dwarf::Dwarf(std::__1::basic_string, std::__1::allocator >)", referenced from: _main in Principale.o ld: symbol(s) not found for architecture x86_64
Thank you in advance.