It is a pure virtual function.
The =0
is just the syntax used to indicate that it is a pure virtual function.
Presence of a Pure virtual function in a class makes the class an Abstract class. One cannot create an object of any abstract class. Although, a pointer or reference to such an Abstract class can be created. Your derived class needs to override that method.
What is the purpose of making a function pure virtual?
Usually, A function is made pure virtual so that the designer of the Abstract Base class can enforce the derived class to override that function and provide it's own implementation. Important to note though, that a pure virtual function can have a implementation of its own, so the derived class can call Base class version of the function.
Sometimes a pure virtual function is added just to make the base class Abstract (so it's instances cannot be created). Usually, in such a situation instead of adding a dummy function to make a class Abstract the destructor of the class is made pure virtual.
pure virtual
, they just require you to set it equal to zero. Someone also mentioned that if you're using <windows.h>, you should just be able to useNULL
instead of 0, if you want to improve readability/comprehension. – Cryptography