Thread: throw in method declarations

  1. #1
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002

    throw in method declarations

    What does "throw" do when used in a method declaration?

    For example, here is a std::exception constructor:

    exception () throw();
    Why is throw used here?
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    It lets you specify which exceptions the member function will throw. In this case, the std::exception constructor is guaranteed not to throw any exceptions.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. on method pointers and inheritance
    By BrownB in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2009, 07:50 PM
  2. Replies: 2
    Last Post: 01-22-2008, 04:22 PM
  3. Why does C++ need throw()
    By meili100 in forum C++ Programming
    Replies: 19
    Last Post: 11-10-2007, 12:34 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Parent/child object design
    By lyx in forum C++ Programming
    Replies: 6
    Last Post: 11-28-2003, 09:46 AM