Interface Inheritance
Get familiar with the concepts of interfaces in general and the interface inheritance in detail.
Interfaces
The interface
keyword is for defining interfaces in class hierarchies. interface
is very similar to class with the following restrictions:
-
The member functions that it declares (but not implements) are abstract even without the
abstract
keyword. -
The member functions that it implements must be
static
orfinal
. (static
andfinal
member functions are explained later in this chapter.) -
Its member variables must be
static
. -
Interfaces can inherit only interfaces.
Despite these restrictions, there is no limit on the number of interfaces that a class can inherit from. This is unlike classes where a class can inherit from up to one class only.
Definition
Interfaces are defined by the interface
keyword, the same way as classes:
interface SoundEmitter {
//....
}
An interface is for declaring member functions that are implicitly ...