Inheritance and polymorphism are the most powerful features of Object Oriented Programming Languages. With inheritance and polymorphism, we can achieve code reuse.
There are many tricky ways for implementing polymorphism in C.
The aim of this article is to demonstrate a simple and easy technique of applying inheritance and polymorphism in C. By creating a VTable (virtual Table) and providing proper access between base and derived objects, we can achieve inheritance and polymorphism in C. The concept of VTable can be implemented by maintaining a table of pointers to functions. For providing access between base and derived objects, we have to maintain the references of derived object in the base class and the reference of the base object in the derived class.