Jaypee University of Engineering and Technology
B. Tech. (CSE) - II Semester
Object Oriented Programming (CS102)
Tutorial – 10
Q1. If a base class contains a member function basefunc(), and a derived class does not
contain a function with this name, can an object of the derived class access basefunc()?
Q2. If a base class and a derived class each include a member function with the same
name,which member function will be called by an object of the derived class, assuming the
scope-resolution operator is not used?
Q3. Imagine a publishing company that markets both book and audio cassette versions of its
work. Create a class publication that stores the title (a string) and price (type float) of a
publication. From this class derive two classes: book, which adds a page count (type int), and
tape, which adds a playing time in minutes (type float). Each of these three classes should
have a getdata() function to get its data from the user at the keyboard, and a putdata() function
to display its data. Write a main() program to test the book and tape classes by creating
instances of them, asking the user to fill in data with getdata(), and then displaying the data
with putdata().
Q4. Write a C++ program to demonstrate the use of parameterized constructors in both base
and derived classes. Create a base class Person that contains data members such as name and
age, and initialize them using a parameterized constructor. Then derive a class Student from
Person, which includes additional data members such as roll_no and marks. Use a
parameterized constructor in the derived class to initialize its own data members as well as
invoke the constructor of the base class. In the main() function, create an object of the derived
class and display all the details using a member function.
Q5. Consider the following declaration and answer the questions given below
class PPP class QQQ : private PPP class RRR : public QQQ
{ { {
int H; int T; int M;
protected : protected : public :
int S; int U; void disp();
public : public : };
void input (int); void indata(int, int);
void out(); void outdata();
}; };
i. Name the base class and derived class of the class QQQ.
ii. Name the data member(s) that can be accessed from function disp().
iii. Name the member function(s), which can be accessed from the objects of class RRR in
main function.
iv. Is the member function out() accessible by the object of the class QQQ?