i have read about this metrial and i am still dont understand it’s core
e.g:
public static void Main()
{
person []p = new person[]{new student(),new worker()};
}
public class person
{
public void f1() { }
public virtual void f2() { }
}
public class student:person
{
public override void f2() { }
}
public class worker:person
{
public override void f2() { }
}
does p[0] has it’s own virtual table as an instance and so p[1] with one entry with f2 so every instance has it’s own virtual table ?
does every object has it’s own virtual table ?
Virtual table is tied to object’s type (i.e. class). But every object (instance of a reference type) has a pointer to its type, and therefore indirectly to its vtable.
If you are interested in C#, there is a neat article here which describes .NET CLR internals: CodeProject .NET Type internals.