Memory Layout difference between nested classes and multiple inheritance in C++?

前端 未结 4 1919
盖世英雄少女心
盖世英雄少女心 2020-12-19 18:59

I am trying to understand how COM specifies the layout of its objects so that a client that wants to use a COM object knows how to do it.

I\'ve read that a COM obje

4条回答
  •  鱼传尺愫
    2020-12-19 19:11

    COM is completely agnostic of the memory layout of your object. All that it wants and needs is a table of function pointers when it calls IUnknown::QueryInterface(). How you implement it is completely up to you. MFC uses nested classes, just about anything else leverages the built-in support for multiple inheritance in the C++ compiler. The way the MSVC++ compiler implements it is completely compatible with what COM needs. This is no accident. Use the boilerplate code you see listed in books about COM that shows how to properly implement IUnknown.

提交回复
热议问题