Edit: I stand corrected on the first part of my answer. I was lazy and didn't check the indenting.
As for SwordPick, that's an integer. How is the compiler supposed to call the GetDamage class function on an integer? Oh wait, it's not an integer. It's a double? A string? Who knows. You never created any object named SwordPick.
class Player {
private:
int health;
int weapon;
public:
Player() {
health=100;//1-100
weapon=0;//0-3
}
void TakeDamage(int dmg) {
health -= dmg;
}
void output_health() {
cout << health << endl;
}
// weapon pickup
void PickupSword(Sword* SwordPick) {weapon=1;}
//void PickupBowarrow(Bowarrow* BowarrowPick) {weapon=2;}
//void PickupAxe(Axe* AxePick) {weapon=3;}
void attack(Player* enemy){
if (weapon=1) {
enemy->TakeDamage(SwordPick->GetDamage()* SwordPick->GetQuality()/10);
SwordPick->SetQuality(GetQuality()-1);
cout << "enemy health = " << enemy->output_health << endl;
cout << "weapon quality = " << SwordPick->GetQuality << endl;
}
//if (weapon=2) {enemy->TakeDamage(BowarrowPick->GetDamage()* BowarrowPick->GetQuality()/10;}
//if (weapon=3) {enemy->TakeDamage(AxePick->GetDamage()* AxePick->GetQuality()/10;}
//if (weapon=0) {cout << "does not have a weapon" << endl;}
}
};
On that note, jay75 please indent your code in the future.
The problem is SwordPick is being passed in to PickupSword but it is never being assigned after that. There is also some back-and-forth here where you have a Sword pointer being passed in but only using an int to identify the weapon. Consider giving the player a Sword* as a member (or, better yet, use inheritance/polymorphism and give the player a Weapon* as a member and have Sword, Bowarrow, and Axe inherit from Weapon). This would save you from using ints or enums to check which weapon they have.