No match for operator== ...

I'm having a slight problem with the following 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
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

//Math functions (censored)

int main()
{
char A='A', S='S', M='M', D='D', s='s', E='E';
string options;
float a, b, c, d, e, f, g, h, i, r;

do
{
printf ("What would you like to do?\n \n A - Addition\n S - Subtraction\n M - Multiplication\n D - Division\n s - Square Root\n E - Exit\n \n");

cin >> options;

if (options == "A")
{
//Addition
}

else if (options == "S")
{
//Subtraction
}

else if (options == "M")
{
//Multiplication
}

else if (options == "D")
{
//Division
}

else if (options == "s")
{
//Square Root
}

else if (options == "E")
{
return 0;
}

else
{
printf ("\n");
printf ("Incorrect symbol\n");
}

printf ("\n");

} while (options == 'A'|'S'|'M'|'D'|'E'|'s');
}


The underlined code has an error (According to MinGW CMDline) that says this:

name.cpp:line: error: No match for 'operator==' in 'options == '(first letter in the line)''

I've tried just about everything I can think about with debugging... I'm also a beginner so I don't know how to debug that well... Anyone know what's up? :\

EDIT:: It does the same thing without the single quote-marks.
Last edited on
Well, first off, you are using the bitwise | operator, which will completely screw it up...you want the logical or (||). Secondly, you can't do it the way you are doing it, you must do it this way:

while (options == "A" || options == "S" || /*...*/);
Topic archived. No new replies allowed.