See there ^ Class zombie is missing ; at the bracket at the end, I added it in red.
Code:
user.takedamage (attackpower);//'user' undeclared (first use this function)
There's no such thing as "user" in your class - what's it supposed to be? You must declare (or define) something that's used!
Same thing here with class player - all classes must begin with { and end with }; (notice the ; at the end).
Code:
bob.takedamage (attackpower);//'bob' undeclared (first use this function)
Same thing there - you must define bob.
Code:
zombie bob;//no matching function call for 'zombie::zombie()' //candidates are zombie::zombie (const zombie&), and 'zombie::zombie(int)'
player user;//same as above only 'player::player()'
For both classes, you have but one constructor - and that constructor takes an int as argument. Here you don't pass any argument and the compiler can't find a constructor that takes no arguments, so it complains.
Declare a constructor that takes no arguments or simply pass in the appropriate argument to the constructor.
Code:
while (bob.life() == 1 and user.life() == 1) {
and is not a keyword; what you're looking for is probably && (basically and in C++).
Code:
int life () {
if ( hp > 0 ) {
return 1;
}
if (hp <= 0 ) {
return 0;
}
}
Suggest you do do just
Code:
int life () {
if ( hp > 0 ) return 1;
return 0;
}
}
The compiler can't know with your IFs that you're actually returning a value at all control paths - this will fix the warning.
Same goes for player::life.
Code:
if (attacktype = 1) {
gnaw();
}
if (attacktype = 2) {
bite();
}
if (attacktype = 3) {
moan();
}
= is assignment, not comparison. What you're looking for is ==.
And really start using tabs instead of spaces. I really recommend it - it's much better.
Also remember from before, when they said big names for your classes? Try that. Do Zombie/CZombie or Player/CPlayer. It's better that way.