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

Read numbers form user and place them in array: Program is to read a group numbers of numbers form user and place them in array type of float and sort them void sort(floa

Structures A structure is a derived data type. It is a combination of logically related data items. Unlike arrays, which are a collection of such as data types, structures can

Write a program that predicts users’ age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an initial gues

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

It is a pointer accessible only in the member functions of a struct, class or union type. It points to the object for which the member function is called. Static member functions d

Problem Statement: You have to write a C program to develop a Car Parking Management System for a busy commercial area. The system will record the car plate number, date and time w

Return by reference: The return value of the function must be an address variable.  In following program the function returns the value of x or y and their types are declare

how to write a program using arrays

Destructor: The purpose of destructor is to free the memory when the compiler memory is reduced or not enough to execute certain program. Sometimes there may several objects op