19.3.4 Exceptions and Constructors /
Destructors
- C'tors and d'tors do not return a value
- Throwing an exception is a clean way to indicate failure
- Caveat: Static values are initialized
before main is entered. There is no try block to catch
exceptions
- If a c'tor fails, the object is not created
- The d'tor isn't called
- Subtle source of leaks
(See next slide)
- Two concurrent exceptions will halt the program
- Don't throw exceptions from within a d'tor
prev
|top
|next