I am building a text adventure and hit a snag.
I have classes PERSON, PLAYER, COP, & ENEMY.
Now PERSON is the main class, and PLAYER, COP, and ENEMY are all sub classes of PERSON
all of the function prototypes and definitions work except (2).
public:
WEAPON* GetWeapon();
void SetWeapon(WEAPON newweapon);
The two functions were first prototyped and defined in the PLAYER class and they worked well when I called them
void Battle(PLAYER* player){
cout << "You are holding a " << player->GetWeapon()->GetName() << endl;
}
(I am assuming you understand that WEAPON class has a function GetName() and it returns a string)
However, I also wanted the COP and ENEMY to have them as well so I moved both the GetWeapon() and SetWeapon() functions over to the PERSON class since all 3 classes (PLAYER, COP, & ENEMY) are just inherited classes of PERSON. And this is when I started getting a [Linker error] undefined reference to 'PLAYER::GetWeapon()'
[Linker error] undefined reference to 'PLAYER:: SetWeapon()'
I am using an up to date version of Bloodshed Dev-C++ IDE
I have checked the spelling for any errors and found none in any of the function calls
I have doubled checked that argument types & return types all match but for the life of me can not figure out why I didn't get the error when the two functions were defined in the player class and DO get the error now that they are in the PERSON class which is a parent of the PLAYER class
Thanks for any help