Monday 18 February 2013

Constructor

Points to remember:
1. A constructor is special function of a class, with the same name as of the class name.
2. Constructor never returns a value, not even void.
3. A constructor can not be called or invoked like a function.
4. More than one constructor is called constructor overloading.

Section B

1. Make a class factorial whose members are as given:
factorial ( ) - default constructor to assign 1 to f.
factorial(int n) - a parameterized constructor to assign num=n.
int get() - to find and return the factorial of num.
Write a program to input a number and print its factorial.

2. A class Reverse is defined as follows:
Data members:long integer num
Member functions :
Reverse(long n) : to store value of variable n to num
long findReverse( ) - find and return reverse of the number present in num.
Write a program to input number and by invoking suitable funtion print the original and reverse number.