cout << "Votre attaque a fait " << ((iTurn % 2) ? p1->arme(p2) : p2->arme(p1))
<< " degat, il reste donc a " << ((iTurn % 2) ? p2->getsName() : p1->getsName())
<< " : " << ((iTurn % 2) ? p2->getiVie() : p1->getiVie())
<< " point de vie" << endl;
I have this code and everytime I'm trying to get p2->getiVie() it always returning me 80 wich is the starting number of life of this p2
I guess you will need more things just let me know because I've got alot of classes
also when I get the life of the personnage in the method arme() it's returning me the right number also if I use the getiVie() later on the code it's working
Well, I'm not sure if I can explain it correctly but at least I know how to correct it.
You just have to assign the results of your function to variables before displaying them with cout.
Cout is probably displaying the result of your function as it is when called. So the damage weren't substracted to your character yet.
For example :
1 2 3
int degats = ((iTurn % 2) ? p1->arme(p2) : p2->arme(p1));
int vieRestante = ((iTurn % 2) ? p2->getiVie() : p1->getiVie());
cout << "Votre attaque a fait " << degats << " degat, il reste donc a " << ((iTurn % 2) ? p2->getsName() : p1->getsName()) << " : " << vieRestante << "point de vie"" << endl;