Изменение значений переменных членов объекта C++
Specify a void function called battle (). This function will accept two Player type objects and a double type variable. The function will control which of them two players have a higher level and will add to that player's experience the value of the variable of type double. In essence the double variable will get one a value that corresponds to the experience of winning a battle. Unlike previous work here we want to change the value of the winner's experience! In case where both players have the same level to display the message ΄Tie΄.
может ли кто-нибудь помочь мне найти истину?
Что я уже пробовал:
void battle(Player &player , Player &player1 , double battle_xp){ battle_xp = 1000; if (player.level > player1.level){ player.getExp() == player.getExp() + battle_xp; player.setExp(player.getExp()); } else if (player.level < player1.level){ player1.getExp() == player1.getExp() + battle_xp; player1.setExp(player.getExp()); } else{ cout << "Tie \n"; } };
KarstenK
Почему вы игнорировали предупреждения компилятора вашего кода??? Они являются криком компилятора о вашем запутанном коде.