Hey I wanted to know how you could turn a character '+' into an operator. For example if I had
char op = '+'
cout << 6 op 1;
Thanks.
SImple way is to use a switch statement
switch (op)
{
case '+':
res = x + y;
break;
case '-':
res = x - y;
break;
case '*':
res = x * y;
break;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With