I cannot give you any details on how this is done in IL, but the basic theory is simple.
When the compiler sees a virtual method declaration, instead of attaching a method to a class, it adds it to what is called a vtable (virtual table method) for this class, which contains pointers to functions.
Now, since vtable is part of the class, it is inherited by subclasses, and thus virtual methods are also inherited. Now comes the override bit. When the compiler sees an override in a method declaration, it searches for a vtable , finds a method to override, and changes the function pointer to point to the new definition.
Thus, you get both the inheritance of methods from the parent classes, and the ability to change their definitions in the child classes.
See the Wikipedia article in the Virtual Method Table for more information.
paracycle
source share