Thread: Catch exception by reference

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    14

    Catch exception by reference

    I am looking at some articles about catch exception by reference.
    I don't know what is the difference from this and my usual way as below.
    Could you tell me??
    Code:
    try
    {
    
    
    
    } catch( exception ex)
    {
                 textbox1.text=ex.message;
    }

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    In normal C++, catching by value involves slicing. Usually code throws exception that are derived from std::exception. If you catch by value, you lose the derived part of the exception object.

    Your code however doesn't appear to be standard C++ but I guess the same reasoning may apply.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM