Exception Handling in C++: CS-2303 System Programming Concepts
Exception Handling in C++: CS-2303 System Programming Concepts
CS-2303
System Programming Concepts
(Slides include materials from The C Programming Language, 2nd edition, by Kernighan and Ritchie, from
C: How to Program, 5th and 6th editions, by Deitel and Deitel, and from
The C++ Programming Language, 3rd edition, by Bjarne Stroustrup)
• Exceptions
– Indicate problems that occur during a
program’s execution
– Occur infrequently
• Exception handling
– Can resolve exceptions
• Allow a program to continue executing or
• Notify the user of the problem and
• Terminate the program in a controlled manner
– Makes programs robust and fault-tolerant
CS-2303, C-Term 2010 Exception Handling in C 3
++
2006 Pearson Education, Inc. All rights reserved.
Exception Handling in C++
• Programs can
– Recover from exceptions
– Hide exceptions
– Pass exceptions up the “chain of command”
– Ignore certain exceptions and let someone else
handle them
• An exception is a class
• Usually derived from one of the system’s exception
base classes
• If an exceptional or error situation occurs,
program throws an object of that class
• Object crawls up the call stack