Object Oriented Programming in C++
Object Oriented Programming in C++
Changunarayan, Bhaktapur
Level: Bachelor
Program: B.E.
Course: Object Oriented Programming in C++
Year: 2015
Full marks: 100
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.
1 a)
b)
2 a)
b)
3 a)
b)
objects. Set the first and second city to be Pokhara and Dhangadi. Display the
sum of DistFromKtm of Pokhara and Dhangadi calling AddDistance function
of third City object.
Or
What is de-constructor? Can you have two destructors in a program? Give
example to support your reason.
List out the features of constructor. Explain different types of constructor with 2+5
examples.
Or
What are the advantages of using a friend function? List different types of
classes and explain any two.
Or
Define friend function and inline function. What are the merits and demerits of
friend functions?
Define the terms subtype, subclass and principle of substitutability. What are 3+5
different forms of inheritance? Discuss.
Or
What is a virtual function? When do we make a function virtual and when we
make a function pure virtual? Explain with a suitable example.
Or
How does inheritance reuse the existing code ? Explain them with example.
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)
b)
6 a)
b)
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?
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.
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.
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.
Write short notes: (any two)
a. New and delete operators
b. CRC
c. this pointer
d. Interface and implementation
e. Exception handling
5X2