I am taking a shot at the exercise in this book that I've been reading through. The instructions read "1. Rewrite the Menu Chooser program from this chapter using an enumeration to represent difficulty levels. The variable choice will still be of type int."
Looking back now I realize that the original menu chooser program used a switch and not do while + if else statements. I suppose a switch would make more sense for the current usage but I can't understand why the do while loop will not exit upon entering a number that is not 1,2 or 3. I get the feeling that the answer is probably obvious but I can't grasp it for some reason.
Ah yes, using & instead of or seems to have mostly fixed it. however if I type something that is not an integer then it turns into what I think is referred to as an infinite loop(it just keeps repeating endlessly). Any idea why it does that? I understand that "choice" is an int and therefore putting a non-int into it is kinda a nono but is there any explanation for why it loops infinitely after doing so?
Also can anyone tell me if it looks like I did the exercise right or more specifically if I am using enum in the correct manner?
But then I end up with the issue that it seems I get 2 inputs instead of just one(as it should be). If I enter a letter into the first input then it reruns the loop asking for a choice again(no problem there) but if I enter number it gives me a second input at which point it will act as it should but this second input is not needed or wanted(otherwise all is good).
I figured out the 2 input thing. I didn't realize that "if(!(cin>>choice))" causes it to call for an input. I had thought that it would just work as a modifier for the cin>>choice; that I already had there.
Still would like to know if I am using enum correctly(or rather if I'm even using it at all or if it is just sitting there like an unused variable).