throw in method declarations

This is a discussion on throw in method declarations within the C++ Programming forums, part of the General Programming Boards category; What does "throw" do when used in a method declaration? For example, here is a std::exception constructor: Code: exception () ...

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

    throw in method declarations

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

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

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

    BigAngryDog.com

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    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, 03:39 PM
  5. Parent/child object design
    By lyx in forum C++ Programming
    Replies: 6
    Last Post: 11-28-2003, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21