in the following code:
switch(a)
{
case '+' :
result=num1+num2;
break;
case '-' :
result=num1-num2;
break;
case '*' :
result=num1*num2;
break;
case '/' :
result=num1/num2;
break;
case '^' :
result=pow(num1,num2);
break;
default :
cout << "Invalid operator" << endl;
}
is the char pointer, and the error is: error: switch quantity not an integer...
If
a
is a pointer, you cannot use it in theswitch
: you need to dereference it first - either like thisor like this