So i'm looking for some input/consensus on what terminology we should be using to describe something that looks like this:
class Printable
{
public:
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?
static const int Foo = 42;
orenum colors {Red, Green, Blue};
in such classes, too. – MSalters Aug 22 '13 at 12:00