In this answer to "In C++ why and how are virtual functions slower?", the author mentions below point:
"Get the right function address from the vtable into a register (the index where the correct function address is stored is decided at compile-time)."
As a follow up of this comment, i have some questions:
What is the order of function pointers stored inside the
vtable
? Is it compiler dependent or all compilers have to implement it the same way?If compilers are free to implement it in their own way, then how does binary standard's like
COM
works.COM
relies on the assumption thatvtables
are implemented in a uniform way by compilers, in order to passIUnknown
pointers to a component compiled by a different compiler. Isn't it?