interface, __interface

https://msdn.microsoft.com/en-us/library/7st4ta52(v=msdn.10)

C++ and Microsoft Specific

A Visual C++ interface can be defined as follows:

  • Can inherit from, at most, one base class.
  • Can only contain public, pure virtual methods.
  • Cannot contain static methods.
  • Cannot contain data members.

A C++ class or struct could be implemented with these rules, but interface (or __interface) enforces them.

By default, only the __interface keyword will be enabled. If you want to use interface as a keyword, see pragma keyword. If you use interface, be aware that some header files may still define:

#define interface struct

In this case, you would have to issue:

#undef interface

For example, the following is a sample interface definition:

interface IMyInterface {
HRESULT CommitX();
HRESULT get_X(BSTR* pbstrName);
};

Notice that you do not have to explicitly indicate that the function is pure virtual. An equivalent declaration for the first function would be:

virtual HRESULT CommitX() = 0;

END C++ and Microsoft Specific