Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling errors with iostream

Tags:

c++

iostream

I'm working on [Bjarne_Stroustrup]Programming-Principles-and-Practice-Using-C++ book from 2008, 5. chapter called Errors is using std_lib_facilities.h and function called error.

Here is example :

if(x<=0) error("non-positive x");
if(y<=0) error("non-positive y");
int area1=area(x,y);

Since I use Visual Studio 2012 which don't have std_lib_facilities.h, this error handler is not working! What is iostream's error handling function and where can I find and study it?

like image 646
Josip7171 Avatar asked Dec 19 '22 16:12

Josip7171


1 Answers

The C++ Standard Library's header files (iostream, vector, etc.) don't have .h on the end. (Most third-party libraries, however, do use the .h.) Since std_lib_facilities.h does have a .h, it's reasonable to assume it's not a standard library and not something that Visual C++ should be expected to provide.

In this case, a quick Google search reveals that it's provided with your book and downloadable from http://www.stroustrup.com/Programming/std_lib_facilities.h.

like image 68
Josh Kelley Avatar answered Jan 02 '23 06:01

Josh Kelley