OOP (313304) Practical No.14: Write programs to implement Virtual Base Class
A virtual base class is a child class that could have duplicate sets of members inherited from a single base class.
When two or more objects are derived from a common base class, we can prevent multiple copies of the base class from 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 a virtual base class. This can be achieved by preceding the base class's name with the word virtual.
OOP (313304) Practical No.14 Exercise:
1. Write a C++ program to implement the concept of Virtual Base Class for the following figure. Assume suitable data and function members.
Answer:
2. Write a C++ program to implement the concept of Virtual Base Class for the following figure. Accept and display information on one employee with his name, code, basic pay, experience, and gross salary with the object of employee class.
Answer:
Practical Related Questions
1. Write a C++ program to implement the concept of a virtual base class for the following figure.
Answer:
2. Write a C++ program to implement the given figure class hierarchy. Assume suitable member variables and member functions.
Answer:
3. Complete the following table:
Answer:
Not Available
Conclusion
We successfully completed OOP (313304) Practical No.14, writing C++ programs to implement Virtual Base Class.