Member functions or pointers to them aren’t stored in the object. (virtual
functions are typically called through a pointer stored in a table to which an object has a single pointer to) This would be a huge waste of memory. They’re typically stored in a code memory section, and are known to the compiler. The object (*this
) is typically passed as an invisible parameter so the functions know on which object to operate when they are called.
So, in layman terms, you’d have
0x10001000 void A::foo
.......... {code for A::foo}
and
push a;
call A::foo (0x10001000)
pop a;
where a
is the object you’re calling foo
on.