Question 0-10

Explain how the VMT works in generating compiled code for object-oriented languages.

Solution

The compiler generates a VMT for each class defined by the program, and it places a pointer to the VMT in each instance of the class. In the compiler-generated code for calling a virtual method on an instance, the CPU looks into the VMT for that instance and enters the method whose address is found there.

Back to Exam 0