'no match for operator =='

So I am really new to C++ and all programming. Like, tonight new. Been fiddleing about with some programs but am stumped on this error -

'no match for operator =='


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
using namespace std;

/*
 * This is a quiz.
 */
int main(){
    
    int option;

    cout << "Please select an option: \n 1) Wipe Drive \n 2) Wipe while preserving installation \n 3) Do nothing" << endl;
    cin >> option;
    cin.ignore();
          
       if (cin == 1) 
            cout << "Wipe progressing.." << endl;
       
       else if (cin == 2) 
            cout << "Preserving Install" << endl;
       
       else 
            cout << "Aborted" << endl;
                 
 
    
    return 0; 


if someone could give me a hand that would be great :)

Thanks

Tom
closed account (28poGNh0)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

int main()
{
    int option;

    cout << "Please select an option: \n 1) Wipe Drive \n 2) Wipe while preserving installation \n 3) Do nothing" << endl;
    cin >> option;
    // cin.ignore(); you dont need this

    if(option == 1)
        cout << "Wipe progressing.." << endl;

    else if(option == 2)
        cout << "Preserving Install" << endl;

    else
        cout << "Aborted" << endl;

    return 0;
}


cin only came with the extractor operator >> as I know !
What do you mean by that?
I removed 'cin.ignore()' but I still came up with the error.

closed account (28poGNh0)
did you notice this line if(option == 1) instead of if (cin == 1)

just copy my source code and compile it
Last edited on
Worked it out... I really am a noob. For the record when using 'if' i should of replaced 'cin' with 'option' (variable)
closed account (28poGNh0)
You not a noob you're cpp programmer that's something

and yes you "should of replaced 'cin' with 'option' (variable)"

hope you the best
I know the question is already answered, but think of it this way- you use cin only when getting computer input, to assign to a variable. From there, you only use what variable you assigned that input to, instead of using cin again.

Hope this helps!
Topic archived. No new replies allowed.