October 09, 2002
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?


October 10, 2002
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?
>
>