Re: CComVariant
George <George@discussions.microsoft.com> wrote:
In your C++ code, you can write a class that derives from two or more
COM interfaces (and often do, for implementation purposes). But this
class itself is not, by definition, a COM interface, since its binary
layout doesn't match the COM specification.
Why it is not? Any COM interface inherits from IUnknown, and I think
any derived class/interface from any COM interface should maintain
the same layout -- i.e. the first 3 methods are
QueryInterface/AddRef/Release.
So suppose I have these interfaces:
interface IA : IUnknown {
HRESULT MethodA();
};
interface IB : IUnknown {
HRESULT MethodB();
};
interface IC : IA, IB {
HRESULT MethodC();
};
What should IC's vtable look like, in your opinion? List all methods in
the order they should appear. Note that the following should work:
IC* pC = ...; // initialized somehow
IA* pA = pC;
IB* pB = pC;
pA and pB should point to vtables compatible with IA and IB,
correspondingly.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925