C++ Tutorial: Some Lab Assignments on Virtual Functions

Question: Write a program to create a class shape with functions to find area of the shapes and display the name of the shape and other essential component of the class. Create derived classes circle, rectangle and trapezoid each having overridden functions area and display. Write a suitable program to illustrate virtual functions and virtual destructor.


Question: Create a class Person and two derived classes Employee, and Student, inherited from class Person. Now create a class Manager which is derived from two base classes Employee and Student. Show the use of the virtual base class.




Question: Write a program with Student as abstract class and create derive classes Engineering, Medicine and Science from base class Student. Create the objects of the derived classes and process them and access them using array of pointer of type base class Student.



Question: Create a polymorphic class Vehicle and create other derived classes Bus, Car and Bike from Vehicle.With this program illustrate RTTI by the use of  dynamic_cast and typeid operators.


SHARE C++ Tutorial: Some Lab Assignments on Virtual Functions

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *