Lets go over a few things:
Replace or with the actual operator || in c++ which is equivalent to or. (Note that or is a ISO646 standard and can be used, but depends on preference)
Next we need to ensure ch is added for every character you are checking
After that we should have in a more simple form:
return (ch == '(') || (ch== ')') || (ch == '*') || (ch == '-') || (ch == '+');
Note: We can also do it the way you have by if/else
bool is_operator_match = false;
if (ch == '(') || (ch== ')') || (ch == '*') || (ch == '-') || (ch == '+')
{
is_operator_match = true;
}
return is_operator_match;
6
solved I’m trying to create a bool function that evaluates a char and returns true if char is ‘(‘ ‘)’ ‘*’ ‘-‘ ‘+’ [duplicate]