I assume that Laptop is inherited from the computer and explains what happens at all; C ++ implementation details (for optimization reasons) may differ from this general explanation.
Logically, a laptop class definition has a pointer to a computer class definition. An instance of the Laptop class has a pointer to the definition of the laptop class (in C ++, most likely, this is just a reference to an array of function pointers for class methods).
When a laptop object receives a message, it first searches its function table for the appropriate function. If not, it follows the inheritance pointer and looks at the method table for the Computer class.
Now, in C ++, a lot of this happens at the compilation stage, in particular, I believe that the method table is smoothed out, and any calls that can be statically linked are shortcuts.
source
share