Help with an error

Posts 1–4 of 4 · Page 1 of 1
Help with an error
I would like to know what it could be i don't understand the error...

Code:
void Personnage::Jouer(Personnage &david, Personnage &goliath)
{
    int i;

    while (i = 1 || i = 2)
    {
        cout << endl << "Que voulez-vous faire?" << endl;
        cout << endl << "1. Donner de la vie a David" << endl;
        cout << endl << "2. Attaquer Goliath" << endl;

        if (i = 1)
        {
            david.boirePotionDeVie(20);

        }
        else if (i = 2)
        {
            david.attaquer(goliath);
        }
        else
        {
            cout << endl << "Mauvaise touche!" << endl;
        }

        cout << endl << "Voici maintenant les nouvelles statistiques..." << endl;

        cout << "David" << endl;
        david.afficherEtat();
        cout << endl << "Goliath" << endl;
        goliath.afficherEtat();

        if (david.m_vie <= 0)
        {
            david.m_vie = 0;
            cout << endl << "David est mort..." << endl;
            i = 5;
        }
        else if (goliath.m_vie <= 0)
        {
            goliath.m_vie = 0;
            cout << endl << "Bravo! David a gagner!" << endl;
            i = 5;
        }
        else
        {
            cout << " " << endl;
        }
    }
}

Error : Personnage.cpp|86|error: lvalue required as left operand of assignment|

(it refer that line : //while (i = 1 || i = 2)//)
[php]while((i==1) || (i==2))[/php]

= is assigning
== is comparing
Quote Originally Posted by Auxilium View Post
[php]while((i==1) || (i==2))[/php]

= is assigning
== is comparing
That's exactly right. |:

Gewd job Pat.
Ho yeah lol thank u (Yes i know I know it, I just forgot it ) But thank you!
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us