CPP

253
3343 reads

February 20, 2013

Catching Any Exception


In some situations, we may not be able to anticipate all possible types of exceptions and therefore, may not be able to design independent catch handlers to catch them.

315
3363 reads

February 20, 2013

Rethrowing Exceptions


A handler may decide to rethrow the exception caught without processing it. In such situations, we may simply invoke throw without any arguements, like, throw; (see, line 64).

136
2121 reads

February 20, 2013

Exceptions in Hierarchy Class


The correct ordering should be the most derived first. The handlers must be in the order from most derived to the Base class.

108
1801 reads

February 20, 2013

Throwing & Catching Exception


The keyword try is used to preface a block of statements (try block) used which may generate exceptions. When an exception is detected, it is thrown using a throw statement from the try block.

22
1677 reads

February 20, 2013

Passing Array


This example depicts how to pass an array as an argument to a function.

23
1520 reads

February 20, 2013

Modifying Actual Argument: Pointers


This example depicts how the values of actual arguments can be changed successfully making the use of pointers.

29
1578 reads

February 20, 2013

Modifying Actual Argument


This example shows that any changes made to the parameters of a function are not permanent and are not reflected in the actual arguments being changed, when arguments are passed by value.

25
1602 reads

February 20, 2013

Calculating Powers-Rearranged


In this example, a function has been used to calculate the power.
Before main() we have declared the function power() and we have included its definition later.

30
1919 reads

February 20, 2013

Calculating Powers


This example implements and calls a function to calculate x to the power n.

28
1752 reads

February 19, 2013

Ranges of Basic Data types


The program shows the minimum and maximum values that the basic data types can accommodate.