no match for 'operater==' in 'std::cin == "(letter)"

I'm very new to C++ (2 days), and I'm trying to write a simple calculater program.

But each time i try to run it I get this error message on each of my if statements: no match for 'operater==' in 'std::cin == "(letter)"

Here's the code:
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>

using namespace std;

int main()
{cout <<"Please press, \nm for multiplication, \nd for division, \ns for sutraction or \na for addition \n";

//Mutiplication
  if (cin == "m") {

    double thisisanumber2;
    double thisisanumber;
    double thisisanumber3;

    cout<<"Please enter a number ";
    cin>> thisisanumber;
    cin.ignore();
        cout<<"Please enter another number ";
    cin>> thisisanumber2;
    cin.ignore();

    thisisanumber3 = thisisanumber * thisisanumber2;

    cout<<""<< thisisanumber <<" Times "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
    cin.get();}

//Division
if (cin == "d"){

     double thisisanumber2;
    double thisisanumber;
    double thisisanumber3;

    cout<<"Please enter a number ";
    cin>> thisisanumber;
    cin.ignore();
        cout<<"Please enter another number ";
    cin>> thisisanumber2;
    cin.ignore();

    thisisanumber3 = thisisanumber / thisisanumber2;

    cout<<""<< thisisanumber <<" Divided by "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
    cin.get();}

//Subtraction
if(cin == "s"){

double thisisanumber2;
    double thisisanumber;
    double thisisanumber3;

    cout<<"Please enter a number ";
    cin>> thisisanumber;
    cin.ignore();
        cout<<"Please enter another number ";
    cin>> thisisanumber2;
    cin.ignore();

    thisisanumber3 = thisisanumber - thisisanumber2;

    cout<<""<< thisisanumber <<" Minus "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
    cin.get();}

//Addition
if(cin == "a"){
  double thisisanumber2;
    double thisisanumber;
    double thisisanumber3;

    cout<<"Please enter a number ";
    cin>> thisisanumber;
    cin.ignore();
        cout<<"Please enter another number ";
    cin>> thisisanumber2;
    cin.ignore();

    thisisanumber3 = thisisanumber + thisisanumber2;

    cout<<""<< thisisanumber <<" Plus "<< thisisanumber2 <<" Is "<< thisisanumber3 <<"\n";
    cin.get();}

}


Very sorry if it's a simple error, but i'm a complete noob at C++.

Thanking you in advance.
cin == "a"

You are attempting to compare the object cin with the object
"a"


cin is an object of type istream.

"a" is a string literal.

It makes no sense whatsoever to compare an object of type istream with a string literal, and unsurprisingly the compiler has no idea what to do with it.

You're using cin wrongly. Use cin to get something from the keyboard, like this:

1
2
string userInput;
cin >> userInput;


and then compare the string object userInput with things.
Last edited on
Thanks, it's so obvious now you mention it!
The program works fine now.

Thanks again.
Topic archived. No new replies allowed.