www.digitalmars.com         C & C++   DMDScript  

D - How are interfaces implemented?

reply Patrick Down <pat codemoon.com> writes:
interface D
{
  int foo();
}

class A : D
{
  int foo();
}

According to:
http://www.digitalmars.com/d/model.html

A theA = new A();

theA points to memory block like this
offset  contents
------  --------
0:      pointer to vtable
4:      monitor
8...    non-static members

D theD = (D)theA;

How is theD implemented?
Oct 09 2002
parent "Walter" <walter digitalmars.com> writes:
The model.html is way out of date :-( Interfaces are implemented by putting
a pointer to its vtbl[], one for each interface, following the members.

"Patrick Down" <pat codemoon.com> wrote in message
news:Xns92A2B933E11CCpatcodemooncom 63.105.9.61...
 interface D
 {
   int foo();
 }

 class A : D
 {
   int foo();
 }

 According to:
 http://www.digitalmars.com/d/model.html

 A theA = new A();

 theA points to memory block like this
 offset  contents
 ------  --------
 0:      pointer to vtable
 4:      monitor
 8...    non-static members

 D theD = (D)theA;

 How is theD implemented?

Oct 09 2002