CS304 Final Spring2006
CS304 Final Spring2006
CS304 Final Spring2006
What is the name of the function that overloads the + operator for the complex class?
1. add
2. complex add
3. +
4. operator +
5. operator
Write two classes Customer and Account. Declare Account as a friend class of Customer.
a) Write parameterized constructors for both classes i.e. Customer and Account, to initialize their
data members. For Customer class initialize cusbalance to zero.
b) Write a member function of Account class, named setBalance ( ) to assign AccBalance to
cusbalance, which is a data member of Customer class.
Write a member function for the Customer class, named displaytData ( ) to display the values of
Customer’s cusName, cusAddress and cusbalance.
a) Write a C++ program which creates a class Employee with the following attribute
1. name
This class should have a parameterized constructor and destructor, the getter/setter functions and a
virtual member function called pay () that returns the salary of the Employee.
b) Create a class named as Salaried that inherits from class Employee. A Salaried object has the
following attribute
1. salary
This class should also have parameterized constructor and default destructor, setter/getter functions
and a pay () member function.
c) Similarly, develop a class named as Hourly that inherits from class Employee. An Hourly object is
distinguished by the following attributes
1. hours
2. rate
This class should also have a parameterized constructor, default destructor, setter/getter functions and
a pay () member function.
Your program should create objects of Salaried and Hourly classes and then invoke the pay () function
of these classes polymorphicly (through Employee Object)
Write a C++ program to determine the area and perimeter of rectangle according to the length and
width entered by the user. Your code should include a template <class T>.
1: length
2: width
The area and perimeter should be calculated for each int, float and double type data member. Hence the
data member of the class rectangle should be of type Template as well.
Your program should have following member functions of a template <class T>.
1: area ();
This member function will calculate the area of the rectangle. The area of a rectangle can be calculated
by the following formula:
2: perimeter ();
This member function will calculate the perimeter of the rectangle where the formula for perimeter of
rectangle is
Area() and perimeter() member functions should return the same type on which the data is
manipulating. For example
If the area is calculating for a rectangle of int type length and width, then this member function should
return an integer number and vice versa.
Take three instances of one of each type of data members’ int, float, and double for the class rectangle
in main ().
Also write setter and getter for the data member of the class rectangle.
Is there any difference between abstract and base class? If yes, then what is it?