When implementing several COM interfaces at once how do I upcast to IUnknown?

后端 未结 4 1241
野性不改
野性不改 2021-01-21 23:43

Suppose my COM object implements two or more COM interfaces:

class CMyClass : public IPersistFile, public IPersistStream {
};

when implementing

4条回答
  •  粉色の甜心
    2021-01-22 00:12

    IUknown is unimplemented. You need to provide all the implementation of IUnknown. Thus, to QI IUknown, you return the this pointer.

    AddRef, Release and QI are all implemented by you and not on the parent interface anyway so you have no issues just CALLING addref, no casting is required.

提交回复
热议问题