By definition, from the C ++ standard (Β§10.4, Abstract classes, focus):
An abstract class is a class that can only be used as the base class of some other class; no objects of an abstract class can be created except subobjects of a class derived from it. A class is abstract if it has at least one pure virtual function. [Note: such a function may be inherited: see below. -end note]
class point { / ... / }; class shape { // abstract class point center; public: point where() { return center; } void move(point p) { center=p; draw(); } virtual void rotate(int) = 0; // pure virtual virtual void draw() = 0; // pure virtual };
In the example, shape contains two pure virtual methods (which makes it an abstract class), but also contains two non-virtual methods. Everything is good. Thus, your initial definition that an abstract class contains only pure virtual functions is too compressed. Just one of them is enough.
Barry source share