So i'm looking for some input/consensus on what terminology we should be using to describe something that looks like this:

class Printable
    virtual void printTo(Printer *) = 0;
    virtual double getWidthInPoints() = 0;
    virtual double getHeightInPoints() = 0;

So this is a class that only has pure virtual methods. Any class that inherits it needs to implement the whole thing, i.e. there is no partial implementation.

So what is this called?

I have mostly seen two different names:

1) Interface

Used in Windows COM programming (perhaps it came from the IDL), it's a keyword in both C# and Java and also a compiler directive/keyword in Objective-C (but isn't the same thing). I've heard engineers using the phrase 'interface' synonymously with 'API', but, at least in this scenario, it's a single thing whereas an API could comprises more than one.

2) Protocol

I've seen this used in various open-source libraries such as Bloomberg BSL and it's a compiler directive/keyword in Objective-C, but does not necessarily need to be in the inheritance hierarchy. In the broader computer science sense, protocol is a formal definition of information exchange between two parties, like TCP and HTTP, but this definition kind of holds for the above class too.

Is there any clear distinction between these in C++ or are they pretty much interchangeable?

  • In my team, we always call it interface class. Jul 31, 2013 at 14:35
  • Worthy of note: The term "interface" is the third letter in API. Its use in that context is a sort of abbreviation of the term.
    – greyfade
    Aug 22, 2013 at 8:41
  • It's not uncommon to see static const int Foo = 42; or enum colors {Red, Green, Blue}; in such classes, too.
    – MSalters
    Aug 22, 2013 at 12:00
  • 4
    Hopefully your "interface" includes a virtual destructor as well ;) Aug 22, 2013 at 18:11

2 Answers 2


The technical term for a class with a pure virtual function is abstract class, but that terms also applies if the class has additional non-pure virtual functions.

Often the term Interface is used in C++ to describe an abstract class like Printable, that describes a service that can be provided by a range of different, otherwise unrelated classes. This corresponds to the use of the interface keyword in C#/Java.

I have never encountered the term 'protocol' in connection with a C++ class

  • Look where the 'Interfaces (Object Oriented Programming)' Wikipedia article redirects: en.wikipedia.org/wiki/… Jul 31, 2013 at 17:04
  • @JBRWilkinson I would consider this an unfortunate and misleading redirect in the context of C++. The references mentions Objective-C. Jul 31, 2013 at 17:21
  • 4
    @JBRWilkinson: I see where it redirects and it makes it clear that 'protocol' and 'interface' are synonyms in this context. That does not change the fact that 'interface' is the more common term among the C++ programmers that I know. Jul 31, 2013 at 17:22
  • Using the term Interface for C++ has become quite common. However, the term Interface is borrowed from Java. Java standardized the concept of a pure virtual abstract class with the use of Interface.
    – Bill Door
    Aug 1, 2013 at 15:04
  • 1
    Historically, the term in C++ has always been "abstract base class," and a lot of documentation and books use the abbreviation ABC quite liberally. The use of the term "interface" is relatively new in the C++ community, and I, too, have never heard the term "protocol" in a C++ context.
    – greyfade
    Aug 22, 2013 at 8:39
  • You can call C++ class with only pure virtual functions as interface or protocol.

  • Interface and protocol both are the same concept.

  • If you were a java/C# programmer,you call the class with only purt virtual functions as an interface. If you were a Objective-C programmer,you call the class with only purt virtual functions as a protocol!

  • 2
    A "protocol" is the "sequence of actions that have to be taken from cooperating interfaces to perform certain tasks". It cannot be a sinonimous of "interface", since it is defined around interfaces. A protocol describes how interface have to be used. an interface describes what an object exposes. Aug 22, 2013 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.