IDL supports inheritance of interfaces. An IDL interface can inherit all the elements of one or more other interfaces.
For example, the following IDL definition illustrates two interfaces, called
CheckingAccount
and SavingsAccount
, that inherit from interface Account
:
module Finance { interface Account { ... }; interface CheckingAccount : Account { readonly attribute overdraftLimit; boolean orderChequeBook (); }; interface SavingsAccount : Account { float calculateInterest (); }; };
CheckingAccount
and SavingsAccount
implicitly include all elements of interface Account
.
CheckingAccount
can accept invocations on any of
the attributes and operations of this interface, and on any of the elements of
interface Account.
CheckingAccount
object may provide different
implementations of the elements of interface Account to an object that
implements Account
only.
CheckingAccount
and SavingsAccount
:
module Finance { interface Account { ... }; interface CheckingAccount : Account { ... }; interface SavingsAccount : Account { ... }; interface PremiumAccount : CheckingAccount, SavingsAccount { }; };Interface
PremiumAccount
is an example of multiple inheritance in IDL.