A pure virtual function is a function that must be overridden in a derived class and need not be defined. A virtual function is declared to be "pure" using the curious "=0" syntax. For example:
Here, Base is an abstract class (because it has a pure virtual function), so no objects of class Base can be directly created: Base is (explicitly) meant to be a base class. For example:
Abstract classes are immensely useful for defining interfaces. In fact, a class with only pure virtual functions is often called an interface.
You can define a pure virtual function:
This is very occasionally useful (to provide some simple common implementation detail for derived classes), but Base::f3() must still be overridden in some derived class.
If you don't override a pure virtual function in a derived class, that derived class becomes abstract:
之 Bjarne Stroustrup's C++ Style and Technique FAQ