Polymorphism in C++ using Virtual Function OOP

preview_player
Показать описание
Today in this video session we will discuss an important feature of C++, that is called polymorphism. The word polymorphism refers to have multiple form of some object. Similarly in C++ this means an object that maybe object of class, function or operator may have multiple forms. In C++ there are two types of polymorphism.
1. Compile time polymorphism
2. Run time polymorphism
Compile time polymorphism refers to the function overloading and operator overloading. While run time polymorphism refers to virtual function, pure virtual function and abstract classes.
Compile time binding is also called early binding or static binding. In early binding compiler associate call of the function or use of operator to specific function and this will perform the same action on run time.
While in late binding the program decide which function is called from which class at the time of execution.
Here we have also discussed pure virtual function and abstract class concept.
An abstract class is such type of class that contains Pure Virtual Function. We cannot create object of abstract class.
In this session we also discussed difference between virtual and pure virtual function in C++. If a class derived from an abstract class then it is mandatory to provide definition of pure virtual function in all derived classes.
Рекомендации по теме
join shbcf.ru