What is virtual and pure virtual function?
Virtual Function | Pure Virtual Function |
---|---|
Virtual Function has its definition hidden in the Base class | They have no definition in the Base class. |
The derived class can override the virtual function if required. | In the case of a pure virtual function, the derived class has to override it. |
If the derived class fails to override then it has the option to use the virtual function of the base class | It will throw a compilation error if it fails to override pure virtual function. |
BY Best Interview Question ON 03 Nov 2021