There are two basic ways to expose a secondary interface: a) local classes (MFC does that, including some dirty tricks to make this effective) b) multile inheritance (ATL does that) b) is IMO much cleaner, only you can get into problems with method name clashes Some pseudocode for the latter:
class CCoImpl : public IFun, public ITest
{
HRESULT QueryInterface()
{
if (iid == IUnknown) { // always return the same pointer when specifically asked for IUnk; which one doesn't matter
addref, return static_cast(this);
}
if (iid == IFun) {
addref, return static_cast(this);
}
if (iid == ITest) {
addref, return static_cast(this);
}
return E_NOINTERFACE;
}
// IFun methods:
HRESULT GoShopping() { ... }
HRESULT GoRocking() { ... }
// ITest Methods
HRESULT TestCountShoes(....) { ... }
};
you get the idea... Neither way you can expose two dispatch (or dual) interfaces - you can only have obe dispatch-based interface per object.
If I could find a souvenir / just to prove the world was here [sighist]