I am aware that in C++, there is a virtual pointer in each instance pointing to a virtual table. But how is dynamic binding implemented in Java?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I guess I will answer my own question. Basically, an object stores a reference to its class object, where the dynamic binding will be forwarded from an object to.
回答2:
Just to be picky, it's a real pointer to a real table of virtual functions, hence the name "virtual function table," often abbreviated as "vft". It is also commonly abbreviated "vtbl" which doesn't help matters.
Java probably does something fairly similar.