Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just a suggestion - if your COM object does not need to do anything special with COM related stuff then you can implement code such that the real logic that your base COM class does is encapsulated in another plain old C++ class say CBaseLogic. </p> <pre><code>CBaseLogic : IBase class ATL_NO_VTABLE CBase : public CComObjectRootEx&lt;CComSingleThreadModel&gt;, public CComCoClass&lt;CBase, &amp;CLSID_Base&gt;, public ISupportErrorInfo, public IConnectionPointContainerImpl&lt;CBase&gt;, public CProxy_IBaseEvents&lt;CBase&gt;, public IDispatchImpl&lt;IBase, &amp;IID_IBase, &amp;LIBID_ExampleLib { CBaseLogic m_LogicObj; /* Method calls are simply forwarded to this member */ }; CDerivedLogic : public CBaseLogic class ATL_NO_VTABLE CDerived : public CComObjectRootEx&lt;CComSingleThreadModel&gt;, public CComCoClass&lt;CDerived, &amp;CLSID_Base&gt;, public ISupportErrorInfo, public IConnectionPointContainerImpl&lt;CDerived&gt;, public CProxy_IBaseEvents&lt;CDerived&gt;, public IDispatchImpl&lt;IBase, &amp;IID_IBase, &amp;LIBID_ExampleLib { CDerivedLogic m_LogicObj; }; </code></pre> <p>This achieves what you are trying to do with the added advantage of </p> <ol> <li>Keeps your real program logic separate from the infrastructure / packaging (COM)</li> <li>Makes the real logic platform independent. </li> <li>Future maintainer need not understand your clever COM hack</li> <li>Keeps your program logic clean and away from the COM syntax, improving readability</li> <li>Makes re-use of real logic easier in other forms of packaging eg as a C DLL</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload