In my opinion, both methods are good, but the second is "prettier."
When programming, it is important to write code in the simplest way that you can think of, and make it easier for other programmers to understand your code if you are replaced or for some other reason.
There are no problems with the complex with your two codes, so they are both beautiful, as I said, but I think I don’t like the first code, this is using the "return" statment without the real need for a "return", here.
There is another way to write this code, better than your path (in my opinion), but not better than your teacher.
int main() { bool ShouldExit = false; while ( true ) { OutputMenu(); string UserChoice; cin >> UserChoice;
Another important reason why I don’t like your first code and my code above, because of the use of an infinite loop, when you use yourself in infinite loops, it is only a matter of time until you make more complex programs with basic errors in him.
Again - everything that I wrote, in my opinion, and not the truth of the gospel.
Rotem
Rotem source share