I have hierarchy of public interfaces like this:
struct ISwitchable {
/* Obtain pointer to another implemented interface of the same instance. */
virtual int switch(unsigned int interfaceId, void** pInstance) = 0;
};
struct IFoo : public ISwitchable { /* Methods */ };
struct IBar : public ISwitchable { /* Methods */ };
struct IFooBar : public IFoo, public IBar { /* Methods */ };
Class implementing IFooBar is placed into dll along with factory function. Client code loads dll, uses factory function to create class instance and use it according interfaces (they are supplied as a header file).
Scheme works fine with dll made by MSVC and client code made by Borland C++ Builder 6.
I introduce virtual inheritance into hierarchy:
struct IFoo : public virtual ISwitchable { /* Methods */ };
struct IBar : public virtual ISwitchable { /* Methods */ };
And when in the same situation (dll by MSVC, client by Builder) client code requests instance of class he gets it with messy vtable.
Is there any solution except of rollback to ordinary inheritance?