Exceptions - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Exceptions

Description:

... which occurs in block is forwarded to exception handler designed by catch clause. ... May use (...) as catch clause, which matches any exception. Throw statement ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 7
Provided by: stude808
Category:

less

Transcript and Presenter's Notes

Title: Exceptions


1
Exceptions
2
  • C Exceptions are used to propagate unexpected
    or severe errors.
  • Section of code which may have error is put into
    try block.
  • Any error which occurs in block is forwarded to
    exception handler designed by catch clause.
  • Normal flow control is interrupted.

3
  • If current function does not catch function,
    exception propagation continues in the calling
    function.
  • Destructors of local objects are executed as
    objects destroyed.
  • Propagation continues until exception caught or
    main is exited.

4
Catch clauses
  • May have multiple catch clauses.
  • Matching is done in order encountered.
  • Derived classes will match specifications of base
    classes.
  • May use () as catch clause, which matches any
    exception.

5
Throw statement
  • Exception started with throw statement.
  • May throw an object of any type.
  • Good design practice to derive exceptions from
    exception class.
  • Message passed to constructor.
  • provides what( ) function which returns message
    that is passed.

6
Standard exceptions
  • in ltstdexceptgt
  • logic_error
  • domain_error
  • invalid_argument
  • length_error
  • out_of_range
  • runtime_error
  • range_error
  • overflow_error
  • underflow_error
Write a Comment
User Comments (0)
About PowerShow.com