How does the C++ compiler know which implementation of a virtual function to call?

后端 未结 6 2023
北恋
北恋 2020-12-03 00:10

Here is an example of polymorphism from http://www.cplusplus.com/doc/tutorial/polymorphism.html (edited for readability):

// abstract base class
#include <         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 00:52

    To answer the second part of your question: that address probably won't have a v-table in the right place, and madness will ensue. Also, it's undefined according to the standard.

提交回复
热议问题