I have a Character .h/.cpp, an Enemy .h/.cpp and a Driver
If I pass the character into a function from Enemy, I have
ENEMY.CPP: void Enemy::enemyAttack(Character *character)
{ //whatever needs to be done }
which works fine.
But back in my Driver, if I do this:
Character *character = new Character();
Enemy::enemyAttack(character);
I get the following error message: “A nonstatic member reference must be relative to a specific object.” is character not a specific object?
No, the error is talking about an Enemy object. To call a non-static Enemy method you must have an Enemy object.
Think about, when you write
which enemy is it that’s attacking? There isn’t one.