Interfaces are useful for grouping and reusing operations.
You can declare interfaces using the interface
keyword. Its name must be an identifier
.
Composing interfaces
You can use the extends
keyword to incorporate operations from other interfaces into a new interface.
Consider the following interfaces:
You can create a new interface C
that includes all operations from A
and B
:
This is equivalent to:
Interface templates
Interfaces can be templated. For more details on templates, see templates.
Templating interface operations
Operations defined within an interface can also be templated. For more details on templates, see templates.