Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Exceptions > Item 12: Understand how throwing an exception differs from passing...

Item 12: Understand how throwing an exception differs from passing a parameter or calling a virtual function

The syntax for declaring function parameters is almost the same as that for catch clauses:

class Widget { ... };          // some class; it makes no
                               // difference what it is

void f1(Widget w);             // all these functions
void f2(Widget& w);            // take parameters of
void f3(const Widget& w);      // type Widget, Widget&, or
void f4(Widget *pw);           // Widget*
void f5(const Widget *pw);

catch (Widget w) ...           // all these catch clauses
catch (Widget& w) ...          // catch exceptions of
catch (const Widget& w) ...    // type Widget, Widget&, or
catch (Widget *pw) ...         // Widget*
catch (const Widget *pw) ...


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint