Get the App
SLTechnology News&Howtos  ›  Development  › 

An example Analysis of C++ 's Virtual function Table access to multiple inheritance

Shulou Source: shulou.com Published: 2022-06-03 05:50:13 11月03日 Update

C++ on multiple inheritance of virtual function table access example analysis, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The following is a routine for accessing virtual function tables with multiple inheritance:

The C++ compiler puts the address of the virtual function table in front of the instance object memory, which is actually a two-dimensional array.

If it is a single inheritance, then the virtual function table is actually an one-digit array.

# include

Using namespace std

Class Base1 {

Public:

Virtual void f () {cout

Tags: Functions caches analysis questions examples actual actually more help answers easy easy digits memory content addresses instances objects guys buddies Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Huawei MySQL macOS