mardi 5 mai 2015

'==' operator not found

So apparently this prgoram is not working. Software tells me that the '==' operator is missing. Could some tell me what to do about this and explain why his/her solution works?

#include <iostream>
using namespace std;

int main() {

    int var{ 0 };

    cout << "Bitte eine Ganzzahl eingeben: ";
    if ((cin >> var) == false) {
        cerr << "Falsche Eingabe - Keine Zahl\n";
        exit(1);
    }


    system("pause");
    //return 0;
}

And while we're at it. Why is it possible to execute 'cin' in the if statemant? I would have used 'cin' before the if statemant.

Aucun commentaire:

Enregistrer un commentaire