Page 215 - DCAP404 _Object Oriented Programming
P. 215
Object-oriented Programming
Notes Multiple Inheritance: A class inherit the attributes of two or more classes. This mechanism
is known as Multiple Inheritance.’
Hybrid Inheritance: The combination of one or more types of the inheritance.
9.10 Keywords
Abstract Class: A class serving only a base class for other classes and no objects of which are
created.
Base class: A class from which another class inherits. (Also called super class)
Containership: The relationship of two classes such that the objects of a class are enclosed within
the other class.
Derived class: A class inheriting properties from another class. (also called sub class)
Inheritance: Capability of one class to inherit properties from another class.
Inheritance Graph: The chain depicting relationship between a base class and derived class.
Visibility Mode: The public, private or protected specifier that controls the visibility and
availability of a member in a class.
9.11 Review Questions
1. Consider a situation where three kinds of inheritance are involved. Explain this situation
with an example.
2. What is the difference between protected and private members?
3. Scrutinize the major use of multilevel inheritance.
4. Discuss a situation in which the private derivation will be more appropriate as compared
to public derivation.
5. Write a C++ program to read and display information about employees and managers.
Employee is a class that contains employee number, name, address and department.
Manager class and a list of employees working under a manager.
6. Differentiate between public and private inheritances with suitable examples.
7. Explain how a sub-class may inherit from multiple classes.
8. What is the purpose of virtual base classes?
9. What will be the output of following code?
Class one
{
public:
one()
{
cout<<“Creating class ONE”;
}
};
208 LOVELY PROFESSIONAL UNIVERSITY