Howdy ! I need guidance on how to properly use exception handling. I want my function to take a single char and if its anything besides a letter, handle the exception and display an error message. Instead of the standard cout print statement if trouble is encountered. Here's what i have so far
I need guidance on how to properly use exception handling
1. Only throw when postconditions cannot be met (note: this implies that constructors always throw and that destructors never throw)
2. Throw by value, catch by reference.
take a single char and if its anything besides a letter, handle the exception and display an error message.
That is not a meaningful use of exception handling, but sure:
I later decided that I prefer a function simply returning false instead of being a void with a throw.
The point is that if a throw occurs, then the entire function stops and we go back to main. This way I didn't try to seekg() on a file that wasn't open.