I'm not a beginner, but I haven't done much with writing my own exceptions.
I'd like to catch exceptions from improper use of iterators.
Here is a piece of code that doesn't properly initialize an iterator.
An exception is thrown when I try to test this iterator against the end of a list.
Windows pops up the following Exception Unhandled window:
---------------------
Unhandled exception at 0x0F25ED76 (ucrtbased.dll) in net_results.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.
---------------------
The execution stops.
I'd like to handle the exception and continue with program execution.
I wrap the code that causes the window to pop up in a try - catch clause but the window pops up and the execution stops anyway.
How would I catch an exception in the following flawed function?
Needless to say, this works only on Windows. Other platforms may just kill your program outright without any exceptions, or they may throw regular exceptions. Strictly speaking, the behavior is undefined. You really should just fix the code, rather than rely on exception handling.