oop - How does object oriented code translate into machine code? -


how oop code write in c++ or c# example translate machine code or in case of c# bytecode? mean, how objects translate?

in procedural programming it's pretty obvious how looks after compilation because there acually real support functions in machine language. in case of oop programing there no objects in machine language.

my theory compiles object sort of c struct contains data (no member functions) , when memeber function called, if accepts addional parameter data struct of object itself. right?

it's implementation dependant. in practice, common thing use virtual table ("vtable"). there's virtual table each class, contains list of pointers implementation of each member function. each object gets pointer appropriate vtable.

depending on language , compiler flags, appropriate pointer in vtable may looked function signature (name , arguments) or index.

when member-function called via it's vtable pointer, sure needs pointer object data. might passed on stack or in register.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -