According to Wikipedia's Virtual function
A virtual function/method is a function/method that can be overridden in an inheritance relationship. You can define (override) both base classes and degraded classes.
A pure virtual function/method is a function/method that must be implemented in the derived class.
Only declarations are possible in the base class, and definitions are possible only in the derived class.
Therefore, writing a pure virtual function/method is the same as writing this class as an interface.
When declaring a pure virtual method in C++, state that it is a pure virtual function by adding =0
at the end.
© 2024 OneMinuteCode. All rights reserved.