Object Oriented Programming in C++
Object Oriented Programming in C++
Changunarayan, Bhaktapur
Level: Bachelor Year: 2015
Program: B.E. Full marks: 100
Course: Object Oriented Programming in C++ Time: 3 hours
NB : Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.
Attempt all questions.
4 Create a class stud_info to take information of student. Derive two classes exam 7
and library to take information related to respective ones for the student. In
main( ), execute all the functions in each classes.
Or
What is memory recovery? How does stack differ from heap memory
Allocation?
Or
What is virtual base class and when do we make a class virtual? Write an
example to illustrate the concept of virtual base class.
b) Is it mandatory to create constructor in derived class if the base class has one? 8
Illustrate giving suitable examples.
Or
Write a program using only constructor to find the area of a square and
rectangle. Also initialize the object dynamically.
Or
In what order are the class constructors called when a derived class object is
created?
5 a) Define early and late binding in C++. When it becomes necessary to make the 3+5
function virtual? Explain giving an example.
Or
What is hybrid inheritance? Does ambiguity occurs in this type of in this type
of inheritance? If yes explain it.
Or
When do we make a virtual function pure? What are the implications of
making a function pure virtual function?
b) What are the operators that cannot be overloaded? Write a program to find 1+6
factorial of a given number n overloading ++ operator.
Or
Develop a complete program for an institution which wishes to maintain a
database of its staff. Declare a base class STAFF which include staff_id and
name. Now develop records for the following staffs with the given information
below:
i. Lecturer (subject, department)
ii. Administrative staff (post, department)
Each staff members should inherit staff_id and name from base class.
Or
Write a program to generate the Fibonacci series overloading ++ operator.
6 a) Write a program to convert given polar number to rectangular representation. 7
(Use concept of type conversion)
Or
What is exception handling? Discuss about the try throw and catch statements
Or
We have two classes X and Y. If a is an object of X and b is an object of Y and
we want to say a=b; what type of conversion routine should be used. Give an
example to illustrate.
b) What is STL? Explain about function and class templates with suitable 2+6
examples.
Or
Write a program using template to add two integers; two floats and one integer
and one float numbers respectively. Display the final result in float.
Or
A template can be considered as a kind of macro. Explain the difference
between them.
4 Write short notes: (any two) 5X2
a. New and delete operators
b. CRC
c. this pointer
d. Interface and implementation
e. Exception handling