Escolar Documentos
Profissional Documentos
Cultura Documentos
PK
www.vustuff.com
CS304
Final Term Examination – Spring 2006
Time Allowed: 150 Minutes
Wr ite two classes Customer and Account. Declar e Account as a friend class of Customer.
a) Write parameterized constructors for both classes i. Customer and Account, to initialize their
e. members. ForCustomer class initialize cusbalance to zero.
data
b) Write a member function ofAccount class, named setBalance ( ) to assign AccBalance to
cusbalance, which is a data member ofCustomer class.
W rite a member function for theCustomer class, named displaytData ( ) to display the values of
C ustomer’s cusName, cusAddress and
cusbalance.
1. name
Th is class should have a parameterized and destructor, the getter/setter functions and
virtual member functionconstructor a
calledpay () that returns the salary of theEmployee.
b) Create a class named asSalaried that inherits from classEmployee. A Salaried object has the
foll owing attribute
1. salary
c) Similarly, develop a class named as Hourly that inherits from classEmployee. An Hourly object is
distinguished by the following attributes
1. hours
2. rate
This class should also have a parameterized , default , setter/getter functions
a pay () member function. constructor destructor and
Y our program should create objects Salaried and Hourly classes and then invoke the pay () function
ofof
these classes polymorphicly (through Employee
Object)
1: length
2: width
T he area and perimetershould be calculated for eachint, float and doubletype data member. Hence
data member of theclass should be of typeTemplate as well. the
rectangle
Your program should have following member functionsof a template <class T>.
1: area ();
T his member function will calculate thearea of the rectangle. The area of a rectangle can be calculated
by the following formula:
2: perimeter ();
T his member function will calculate theperimeter of the where the formula for perimeter of
rectangle is rectangle
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 lengthand width, then this member functionshould
return an integer numberand vice versa.
Ta ke three instances of one of each type of data int, float, and doublefor the class rectangle
members’
in main ().
QuestionNo. 8 Marks : 1
There isa class Studen t, Which one of the following is a valid destructor for this class
1. Student();
2. Student(int);
3. ~ Student();
4. int~ Student();
5. ~ Student(int);
Is there any difference between abstract and base class? If yes, then what is
it?