[Solved] Enum and Switch statement C++


I think what you are trying to do is making your code dynamic. Unfortunately, you are doing it completely wrong. Please first clear your concept on enum.

If this is the case, then you can try this-

int a, b;
char op;

cin >> a >> op >> b;

switch(op)
{
    case '+': cout << "addition of two numbers is: " << a + b << endl; break;
    case '-': cout << "subtraction of two numbers is " << a - b << endl; break;
    case '*': cout << "multiplication of the two numbers is " << a * b << endl; break;
    case "https://stackoverflow.com/": cout << "division of the two numbers is " << a / b << endl; break;
    default: cout << "invalid operator" << endl;
}

solved Enum and Switch statement C++