1. How do i control an order of virtual functions within the virtual table? Could they be organized within the same order that they're declared in?

  2. When getting a category having a virtual table, may be the virtual table from the inherited class extra time from the base class, or perhaps is a completely new virtual table produced with just the inherited classes virtual functions. (i.e. may be the virtual table still at index +0x0 from the class?)

That's completely implementation defined. The C++ standard doesn't specify any kind of an online function table whatsoever -- that's precisely how it's typically implemented.

  1. (a) So far as the conventional is worried, you cannot, (actually you cannot even think that vtables exist). (b) Most likely, but do you know the conditions that you have to control an order, however, you can't look for yourself? The best way to check is to check out the disassembly of the virtual call (and discover the offset(s) put into the vtable pointer to obtain the call address) or to check out the disassembly from the vtable itself.

  2. Is dependent. For single inheritance, most likely this is an extension from the base class, and index of every object indicates an online table for that class, with pointer towards the correct implementation (possibly an override) for every virtual function declared in base classes, then pointers to every virtual function declared within the derived class. For multiple and virtual inheritance it is not (can not be) that easy. Each object will contain several pointers, with the idea to vtables in order to structures that have vtables plus other class information, so when you cast round the class hierarchy, the pointer worth of the item changes. Check it out and find out.

All this for any very hypothetical, "typical implementation". Compiler-authors get their methods.

Virtual table is implementation specific. It might be organized in almost any order. Even there might be no virtual table whatsoever to implement polymorphism. I suggest this article on Wikipedia, which provides some solutions for your questions.

While certainly 100% true, another solutions ignore an apparent truth.

It isn't a stupid question, with respect to the posters goals. Very frequently, we are instructed to use platform-specific technologies to attain our goal. Particularly, exactly what the poster is attempting to complete is strikingly much like COM on home windows... writing pure virtual abstract connects that may be based on are among the couple of methods for getting bulletproof C++ DLLs without shedding down again to some C interface.

I went in to the same problem while writing a wordpress plugin architecture in native C++ -- the possible lack of a ABI means that it's incredibly frustrating to interoperate.

The question your question really begs is why can you ever must have the vtable inside a particular order?

A primary reason this really is implementation dependent happens because a compiler could make options concerning how to layout the vtable for performance reasons, or any other needs, particular to some given CPU architecture.