Initially, in v1.0 of CrxOop, CrxOop did not allow the creation of pure virtual methods, while at the same time the
Javscript technology does not allow a satisfactory implementation of multiple inheritance for classes. This leads to
the implementation of what are called interfaces in Java. In C++, these would be classes with only public pure
virtual methods.
Note the following:
- Interfaces do not define variables
- Interfaces do not define full function signatures due to Javascript's limitations, only function names
- Interface supports multiple inheritance to other interfaces
- Interface can not be instantiated
- A class may implement multiple interfaces
-
A class implements an interface by defining a
public virtual function, or a
public pure virtual function with the same
name as the name declared in the interface definition, and doing this for all functions declared in the
interface definition.
-
Although virtual functions may have different accessors set going down the class extension chain, once a
virtual function is required by an interface, pertaining classes in the class extension chain may only
define said virtual function as public.
- Class instances can not be cast to interfaces
-
Interfaces are still a type, and class instances can be
checked against
them