January 2011
Intermediate to advanced
1648 pages
70h 30m
English
Now that you know how virtual calls are made, one remaining question is how a base call avoids getting trapped in some kind of endless recursion. Consider the following code we wrote for Student:

Assume the base call for ToString would be handled in a virtual manner using a callvirt instruction for System.Object::ToString. The innards of virtual dispatch would inspect the v-table of the runtime type of the object (that is, a Student). In the slot for ToString, a reference would be found to the Student’s ToString code, as shown in the preceding code. So we end up where we started, resulting in an endless recursion. Clearly, ...
Read now
Unlock full access