Thank you, Framework!
So, I'm just trying to understand your code.
You used the reference to pass by value in the attack parameter, right?
Oh, and since there is only you, the Player, and enemies, you would have the BaseEnemy target "Player". And since enemies are enemies, you had the BaseEnemy as a base for Trolls, which is inheritance. Then you used a virtual function.
So, the attack function only has 1 parameter, right? The Parameter is a class?
Thanks again, Framework for helping me. Btw, what if we put the "health" as a private?
If that's the case then we would need to use a function accessor to access the variable right? Instead of this:
1 2 3 4 5 6 7 8
|
{
void Troll::Attack( Player &Target )
{
Target.Health -= this->AttackMag;
if( Target.Health < 0 )
Target.Health = 0;
}
}
|
instead of that, we would use something like this?
1 2 3 4 5 6
|
{
void Troll::Attack( Player &Target )
{
accesshealthdamage();
}
}
|
something like that? Thank you Framework !