What should one catch?, C/C++ Programming

A: By keeping along with the C++ tradition of "there's more than one method to do that" (translation: "give programmers options & tradeoffs so they can choose what's best for them in their situation"), C++ let you a variety of options for catching.

Ø  Catch by value.

Ø  Catch by reference.

Ø  Catch by pointer.

Actually, you have all the flexibility that you have in declaring function parameters, and the rules for whether a specific exception matches (that means will be caught by) a specific catch clause are almost accurately the same as the rules for parameter compatibility while calling a function.

Given all this flexibility, how do you choose what to catch? Simple: unless there's a good motive not to, catch by reference. Avoid catching by value, as that causes a copy to be made and the copy can have distinct behavior from what was thrown. Only under extremely special circumstances should you catch by pointer.

 

Posted Date: 3/19/2013 8:56:10 AM | Location : United States







Related Discussions:- What should one catch?, Assignment Help, Ask Question on What should one catch?, Get Answer, Expert's Help, What should one catch? Discussions

Write discussion on What should one catch?
Your posts are moderated
Related Questions
Explain the Command Line Parameters? The Command line arguments are parameters supplied to a program from the operating system. These arguments are parameters accepted to main

Define Passing Structure to a Function? A structure is able to be passed as a function argument identical to any other variable. If we are merely interested in one member of a


The program reads two numbers and a character (operator). If the character is "+" then sum is displayed. If it is "-"then difference is displayed. If it is "*" then product is disp

Question A bank normally updates it's clients accounts at the end of each month.Of the two types of bank accounts:savings and checking, a client must maintain a minimum balance

Programming Assignment #3: Vehicle Track Performance Tests Purpose: The purpose of this programming assignment is to give the student experience in using functions, arrays, and str


reocord of a student and a function ctotal to calculate the marks of any three subject by using ctotal() function

Convert coordinate: class rect{                 private :                 float  x,y;                   public :                 void  input()