I have two classes, which is all fine and dandy as you would expect. One is a generic PLAYER class and another is a generic NPC class (I was really just messing around to help someone else out)....
The two classes are as follows:
class PLAYER
{
public:
double health;
double offensive;
double defensive;
PLAYER ()
{
health = 100;
offensive = 20;
defensive = 20;
}
int TakeDamage (int Damage)
{
//int diff = (defensive - opponent.offensive);
health -= Damage;
if (health <= 0) {return 0;} else {return 1;}
}
};
class NPC
{
public:
bool isenemy;
bool willattack;
double health;
double offensive;
double defensive;
NPC ()
{
isenemy = true;
willattack = false;
health = 100;
offensive = 20;
defensive = 50;
}
int TakeDamage (int Damage)
{
health -= Damage;
if (health <= 0) {return 0;} else {return 1;}
}
};
As you can see there is a TakeDamage function for these that allow you to specify how much you want to danage the character. But I want to be able to give an NPC as the argument for TakeDamage (and PLAYER for the NPS's TakeDamage function).
If I just go something like this:
int TakeDamage (NPC opponent)
{
//int diff = (defensive - opponent.offensive);
//etc....
}
it gives me the following error:
'opponent' has incomplete type
Is there something I have to do to the class to allow it to be used like this (as a type)?
__________Michael Dawson"IRC is just multiplayer notepad." - Reverend