"George" <George@discussions.microsoft.com> wrote in message
I think it means even if the pointer binary values are different,
they may still be pointed to the same object? Right?
Right. The same COM object (as determined by COM identity check) - not
necessarily the same C++ object (but that's an implementation detail
you, as a COM client, shouldn't care about).
I think it happens only in the situation of multiple inheritance, and
in single inheritance, there is no such issue. Right?
Inheritance (whether single or multiple) is not the only possible
technique of implementing COM objects. There are many different ways,
some of which may lead to this situation. For example, read about
tear-off interfaces in the same book.
I think the above statement describes the following scenario, in
multiple inheritance, suppose we have interface A inherits from
IDispose, and interface B inherits from IDispose
You probably mean IDispatch, not IDispose.
and have inteface C
inherits from both A and B.
There ain't no such thing as multiple inheritance of COM interfaces. An
interface is always derived from exactly one other interface (except
IUnknown which doesn't have a base interface).
However, a COM object can implement both A and B (though this is usually
a bad idea unless special precautions are taken). Then you can do
something like this to end up with two different IDispatch pointers
pointing to the same object:
IUnknown* pObj; // points to the COM object in question
IDispatch* pDispA = pA;
IDispatch* pDispB = pB;
// Two pointers are not equal
assert(pDispA != pDispB);
// ... but refer to the same COM object
assert( CComPtr<IDispatch>(pDispA).IsEqualObject(pDispB) );
With best wishes,
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