Virtual Function Table Offset

I would like to ask you what the offset of the virtual function table for the class depends on. I mean, what I read at least depends on the compiler, but does it change from class to class?

Edit: by offset I mean the position of the table relative to the address of the owner object.

Edit: sample code:

void **vtable = *((void***)(((char*)object)+offset));

int **ivtable=(int **)vtable;

void* firstFunction = (void*) ivtable[0];
+3
source share
3 answers

There is a certain dependence on the exact class.

, ++ (MI). MI , . , . , 0.

MI vtables: , . vtable MI.

MI , . , SecondBase* Derived sizeof(FirstBase), - Derived.

+4

, / ++ Windows . Microsoft COM , ++- COM- Windows ++.

, - , (1- , ), - . , "" ( virtual ).

+3

.

0
source

Source: https://habr.com/ru/post/1729748/


All Articles