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
In this lab, please complete a given program to perform the following tasks: 1. Allocate a 10 by 5 2D byte array dynamically. The way of allocation must be consistent with page

You are to develop a Clinic System. 1. Identify and briefly explain the objects, classes, methods and attributes for the Clinic System. 2. Draw a use case diagram to represen

A Constructive Example Consider an example , to model a user-defined data type for  strings. The object simulates a character array ( string ) using a character pointer and an

Project Description: I want someone with experience on adding/compiling/installing the OpenVPN client software within an IP network camera's embedded operating system. Either if

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b


Default argument: When the argument is missing then the function will read the default value of the missing argument.  To make use of default argument functionality the argu

Available, and the right kind of programs. My son wants to stop using ice. He has organised detox a number of times, and is always successful. It is the next stage, rehab, where

progarm in c for area under curve   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area; int numtraps;

enter height of the shape: 1 3 5 3 1 3 5 7 5 3 5 7 9 7 5 3 5 7 5 3 1 3 5 3 1