Handling Exceptions
This chapter will begin our quest to expand your C++ programming repertoire beyond OOP concepts, with the goal of enabling you to write more robust and extensible code. We will begin this endeavor by exploring exception handling in C++. Adding language-prescribed methods in our code to handle errors will allow us to achieve less buggy and more reliable programs. By using the formal exception handling mechanisms built into the language, we can achieve a uniform handling of errors, which leads to more easily maintainable code.
In this chapter, we will cover the following main topics:
- Understanding exception handling basics –
try
,throw
, andcatch
- Exploring exception handling mechanics – trying code that may raise exceptions, raising (throwing), catching, and handling exceptions using several variations
- Utilizing exception hierarchies with standard exception objects or by creating customized exception classes
By the end of this...