Program to demonstrate default arguments and constant arguments for a function

Q.5) a) Write a program to demonstrate default arguments and constant arguments for a function.

Ans.


You can call a function a function without passing all its parameter but you have to specify default values when the function is declared. You can only provide the default values from right to left as a parameter in the function. Default arguments plays important role when some arguments always have same value.

Some example of default arguments are as follows.

int sum(int a,int b,int c=30)
int sum(int a,int b=20,int c=30)



b) What is RTTI? Suggest some cases where we need to use RTTI .

Ans.


Run-Time Type Identification (RTTI) is a technique that is used to know the type of any object at run time. Base-class pointers may be used to point to objects of the base classor any objject derived from that base. What type of object will be pointed by a base classpointer is not known at compile time.

This determination must be made at run time, using run-time type identification.

Post your comment