---
description: "Learn more about: __interface"
title: "__interface"
ms.date: "05/07/2019"
f1_keywords: ["__interface_cpp"]
helpviewer_keywords: ["__interface keyword [C++]"]
ms.assetid: ca5d400b-d6d8-4ba2-89af-73f67e5ec056
---
# __interface
**Microsoft Specific**
A Microsoft C++ interface can be defined as follows:
- Can inherit from zero or more base interfaces.
- Cannot inherit from a base class.
- Can only contain public, pure virtual methods.
- Cannot contain constructors, destructors, or operators.
- Cannot contain static methods.
- Cannot contain data members; properties are allowed.
## Syntax
```
modifier __interface interface-name {interface-definition};
```
## Remarks
A C++ [class](../cpp/class-cpp.md) or [struct](../cpp/struct-cpp.md) could be implemented with these rules, but **`__interface`** enforces them.
For example, the following is a sample interface definition:
```cpp
__interface IMyInterface {
HRESULT CommitX();
HRESULT get_X(BSTR* pbstrName);
};
```
For information on managed interfaces, see [interface class](../extensions/interface-class-cpp-component-extensions.md).
Notice that you do not have to explicitly indicate that the `CommitX` and `get_X` functions are pure virtual. An equivalent declaration for the first function would be:
```cpp
virtual HRESULT CommitX() = 0;
```
**`__interface`** implies the [novtable](../cpp/novtable.md) **`__declspec`** modifier.
## Example
The following sample shows how to use properties declared in an interface.
```cpp
// deriv_interface.cpp
#define _ATL_ATTRIBUTES 1
#include
[Interface Attributes](../windows/attributes/interface-attributes.md)