Use character variable as operator
I'm trying to use a user-inputted character variable as an operator, similar to the following:
I'm new to programming, and wasn't sure if this is possible. I know how to do it in a different way with a switch statement on the oper variable, but would like to know if it's possible to convert the oper variable in some way that it would be possible to utilize "sum = (num1 oper num2);" without a compilation error. Anyone know?
int num1 = 5;
int num2 = 5;
cin >> oper;
sum = (num1 oper num2);