Intro
I was wondering recently if I miss some C++ class because I did not remember the keyword abstract in C++. Like, there was an abstract class, but not the abstract keyword.
The magic is done via virtual function =0 –> the so-called pure virtual function.
Early binding and late binding
Virtual function & Pure Virtual
class AbstractClass { public: virtual void AbstractMemberFunction() = 0; // Pure virtual function makes // this class Abstract class. virtual void NonAbstractMemberFunction1(); // Virtual function. void NonAbstractMemberFunction2(); };
Virtual functions: the correct function will be called, derived or base class.
Pure virtual functions: It must be overridden by the inherent class.
REFs
[1] https://www.geeksforgeeks.org/virtual-function-cpp/
[2] http://www.cplusplus.com/doc/tutorial/polymorphism/