www.digitalmars.com         C & C++   DMDScript  

D.gnu - Implementation of Interfaces

reply Ingmar Schuster <ingmar.schuster web.de> writes:
Hi,

A quick-and-easy question on the implementation of interfaces in gdc: 
hows it done, with multiple inheritance, interface dispatch tables like 
in gcj or some third method?

Greetings
Ingmar Schuster
Dec 08 2005
parent David Friedman <d3rdclsmail_a_ _t_earthlink_d_._t_net> writes:
Ingmar Schuster wrote:
 Hi,
 
 A quick-and-easy question on the implementation of interfaces in gdc: 
 hows it done, with multiple inheritance, interface dispatch tables like 
 in gcj or some third method?
 
 Greetings
 Ingmar Schuster
Basically, it's multiple inheritance. When a class is declared to implement an interface, a field is added to the class that points to a virtual method table for that interface. If an interface is reimplemented in a descendant class, another field is added instead of using the one from the ancestor class. Both fields will have the same value. Except for COM interfaces, the first entry of the interface virtual method table points to some information that can be used to cast the interface reference back to its object reference. David
Dec 10 2005