Hi all, I'm using the book "Principles and Practice Using C++" by Bjarne Stroustrup to learn C++ at the moment. I'm now on chapter 5, errors.
In this chapter, they provided examples about how to deal with errors.
int x, y;
//if x or y is negative, give error
if (x<0 || y<0) error("non positive inputs");
else int area=x*y;
The issue comes next. When a negative value is entered, I expected a message would pop out, telling me that an error has occurred with the message "non positive inputs" appearing on it. However, I got this error message instead.
"An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in learning_from_book.exe
Additional information: External component has thrown an exception."
When I clicked on break, it opens the header "std_lib_facilities.h" that the book asked us to reference, and points to this segment of the code.
// error() simply disguises throws:
inline void error(const string& s)
So my question is, is the error() doing what it is supposed to do? Because my message didn't appear, I am assuming that it's not working.
EDIT: I forgot to mention I'm using Visual C++ Express 2010.