An object consists of: offset contents ------ -------- 0: pointer to vtable 4: monitor 8... non-static members The vtable consists of: 0: pointer to instance of ClassLayout 4... pointers to virtual member functions
A dynamic array consists of: 0: pointer to array data 4: array dimension A dynamic array is declared as: type array[]; whereas a static array is declared as: type array[dimension]; Thus, a static array always has the dimension statically available as part of the type, and so it is implemented like in C. Static array's and Dynamic arrays can be easily converted back and forth to each other. Reference Types --------------- D has reference types, but they are implicit. For example, classes are always referred to by reference; this means that class instances can never reside on the stack or be passed as function parameters. When passing a static array to a function, the result, although declared as a static array, will actually be a reference to a static array. For example: int abc[3]; Passing abc to functions results in these implicit conversions: void func(int array[3]); // actuallyvoid func(int *p); // abc[3] is converted to a pointer to the first element void func(int array[]); // abc[3] is converted to a dynamic array Class Model ----------- The class definition: class XXXX { .... }; Generates the following: o An instance of Class called ClassXXXX. o A type called StaticClassXXXX which defines all the static members. o An instance of StaticClassXXXX called StaticXXXX for the static members.