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 the switch
: you need to dereference it first - either like this
switch(*a)
or like this
switch(a[0])