8.3. C++

Both Modula-2 and Ada 83 provide different constructs for the interface and the implementation. This is not so with C++ where, if you wish to use this style of programming, the class construct is used for both.

In his fascinating book 'The Design and Evolution of C++' ([16]), Stroustrup (the designer of C++) says: ‘I ... made matters worse for the C++ community by not properly explaining the use of derived classes to achieve the separation of interface and implementation. I tried (see for example Section 7.6.2 of [15]), but somehow I never got the message across. I think the reason for this failure was primarily that it never occurred to me that many (most?) C++ programmers and non C++ programmers looking at C++ thought that because you could put the representation right in the class declaration that specified the interface, you had to.’

To make it easier to express this separation, Stroustrup added the concept of an abstract class to C++. ‘The very last feature added to Release 2.0 before it shipped [in June 1989] was abstract classes. Late modifications to releases are never popular, and late changes to the definition of what will be shipped are even less so. My impression was that several members of management thought I had lost touch with the real world when I insisted on this feature.’

‘An abstract class represents an interface. Direct support for abstract classes

In C++, an abstract class is a class that has one or more pure virtual functions:

class figure
      virtual double area() = 0;
      virtual double perimeter() = 0;