I'm having an issue compiling that code. I know the code dose nothing, but it gave me an error saying " use of undefined type Humans, how can I make it work? how can I make classes that can access other classes instances in cpp ? Thank you :)
#include <iostream>
class Humans;
class Animals
{
public:
Animals() :health(1)
{
}
int health;
void Attack(Humans a)
{
a.health = 10;
}
};
class Animals;
class Humans
{
public:
Humans() :health(0)
{
}
int health;
void Attack(Animals s)
{
s.health = 5;
}
};
int main()
{
Humans max;
Animals lion;
lion.Attack(max);
}