Abstract Class in C++ / ABC



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 {
  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.


[1] https://www.geeksforgeeks.org/virtual-function-cpp/

[2] http://www.cplusplus.com/doc/tutorial/polymorphism/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s