Inheritance - Extending Class - 093906
Inheritance - Extending Class - 093906
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
Conceptual Question/Answer
1. Why the concept of inheritance is introduced in OOPs? Or,
What is the importance of inheritance in context to OOPs? Or,
Discuss various reasons that support the concept of inheritance in Object Oriented Languages.
Inheritance
i) Express the inheritable relationship of real-world models.
ii) Facilitates the code reusability.
iii) Simulates the transitive nature of real-world's objects thereby saves time and efforts on
modification.
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT
8. When does ambiguity arise in multiple inheritance? How can one resolve it?
An ambiguity can arise when several paths exist to a class from the same base class. This means
that a child class could have duplicate sets of members inherited from a single base class. This can
be solved by using a virtual base class.
9. What is a virtual base class? What is its significance?
When two or more objects are derived from a common base class, one can prevent multiple copies
of the base class being present in an object derived from those objects by declaring the base class
as virtual when it is being inherited. Such a base class is known as virtual base class.
Virtual base class prevents the duplication of same object regardless of the number of paths that
exist to the child class.
10. How does the visibility mode control the access of members in the derived class? Explain with
examples.
Visibility mode controls the access of member in derived class by using access specifier. Below table
shows different visibility modes.
*********************
IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUTORIAL POINT IP CS TUT