Thread: Trouble finding answer to professor imposed questions

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    98

    Trouble finding answer to professor imposed questions

    I've read over the chapters where the topics of covered and am still left with a couple questions. If you guys wouldn't mind setting me straight, I'd appreciate it.

    What 3 things happens when this is executed
    Code:
    throw class1();
    and

    Code:
    catch(...);

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    What happens when this is executed?
    Code:
    class1();
    Or this?
    Code:
    throw a;
    Or this?
    Code:
    catch (int i)
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    13
    You are refering to what is know as exception handeling. This paticular mechanism, called try-catch, is found in many popular languages. It is made up of the two blocks, the try blocks and catch blocks. Try basically executes code in block and looks to see if an excpetion is trhown. An exeption is any error that occurs in the program. To let the try know if an expetion occured you use a throw statment such as

    throw exception;

    This is were the catch block comes into play. It is the part that actually deals with the exception. When a try trhows an exception, it immedially haults execution of anything after the throw statement and jumps to the catch block. What you write inside of the catch block to deal with the error is left up to you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c questions again. Please answer.
    By malvado in forum C Programming
    Replies: 39
    Last Post: 06-08-2011, 11:02 AM
  2. Answer to these questions
    By mdennis10 in forum C++ Programming
    Replies: 3
    Last Post: 04-19-2011, 07:48 AM
  3. I'm meeting with a college professor (computer science). Questions...... ->
    By SG57 in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-07-2006, 06:55 PM
  4. A couple of questions that someone might know the answer to...
    By Finchie_88 in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 04-15-2005, 08:26 AM
  5. Questions ab an answer...
    By JohnMayer in forum C Programming
    Replies: 8
    Last Post: 08-11-2002, 11:06 PM