This is a simple C++ Program to demonstrate Inheritance. Simpler methods in the classes have been changed to inline code to shorten the file considerably. In a practical programming situation, methods that are this short should be programmed inline since the actual code to return a simple value is shorter than the code required to send a message to a non-inline method.
In OOP terms, polymorphism represents the ability to resolve a reference to an object’s method at run time. Specifically, different objects could make a call to a Draw or Print method, and these methods would act differently with each object; the process can take different forms behind a common interface. One of the benefits of polymorphism is that because the interface is common to objects, any object is able to respond differently to some common set of tasks, and objects are independent of each other.
Any program which uses these five methodologies or any of it, we can call that program object oriented. They are Encapsulation, Data Hiding, Overloading, Polymorphism, Inheritance. Any programming language which supports all of these features and facilitate the programmer in developing the program in these methodologies is called Object Oriented Programming Language i.e. C++, Java, C#.
Following is the source code of simple queue implementation with the help of Inheritance and Polymorphism i.e. Late Binding.