CS246 Lecture Notes - Lecture 17: Observer Pattern, In C

124 views2 pages

Document Summary

// for a specific exception catch (someexception s) throw someotherexception{ }; Any code in the try block, the program skips to the catch block which is expected to handle it. throw s vs throw. What if the acual exception that was originally thrown was a [subclass/subtype] of the exception (someexception) i caught? throw s would cause object slicing. throw throws the exact object again and is thus preferred. All c++ library exceptions are derived from the exception class. C++ does not require user-defined exceptions to be derived from the exception class. In c++ you can throw anything - int/ bool etc. git pull refactt. cc/efact. cc git pill refib. cc/exfib/cc. Exceptions should be only used for error situations. Advice: create your own exception classes or reuse existing ones. Use abstract base class to define the interface. Use pointers to the base class and never pointer to the subclass [ use the virtual methods.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents