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
Function Templates Function templates give you with the capability to write a one function that is a skeleton, or template, for a family of similar functions. In function ov

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Write a C program to calculate the output Y for a given value of X for the following formula   Y=X 2 + 2X +3   #include stdio.h   void main()   {   char promt;   float y,x

Overall Program Objective: You will design and simulate a basic RISC processor.   You will create and encode an instruction set.  Your final task will be to "compile" a program

Program to store family members details in C++: #include #include #include struct record {   char name[30];   int age;   char state[40]; }x; //cal

how to create the programs in c++ knowledge

We started off taking about input, output, CPU and memory devices. Within C we need a method of storing large amounts of data in memory. We have used the idea of variables (pointer

Question 1 Write a program in ‘C' to check whether a given number is even or odd Question 2 Explain while and do... while loop with an example Question 3 Write a program

Inbuilt Functions i).  Functions to manipulate strings The cstring library defines many functions to perform some manipulation operations with C-styled functions. The followi

Create a mathematical number guessing game. Have the user prompt for the number of games that they want to play. Then each game consists of the following rules. a. The computer