Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CComContainedObjectEx or Pointer to Interface

0 views
Skip to first unread message

K2G

unread,
Nov 24, 2009, 4:40:29 AM11/24/09
to
HI,
Keeping a pointer to interface is better or CComContainedObjectEx
<Interface> as class member is ?
I have class


class ATL_NO_VTABLE CMyClass :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMyClass , &CLSID_CMyClass>,
public ISupportErrorInfo
{
HRESULT FinalConstruct()
{
otherInterface.CoCreateInstance(CLSID_OtherInterface);

return S_OK;
}

private:
IOtherInterface *otherInterface
};

OR


class ATL_NO_VTABLE CMyClass :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMyClass , &CLSID_CMyClass>,
public ISupportErrorInfo
{

private:
CComContainedObjectEx<IOtherInterface > otherInterface;
};


which one is better? and what are the benefits of one over another?

Igor Tandetnik

unread,
Nov 24, 2009, 8:13:56 AM11/24/09
to
K2G wrote:
> Keeping a pointer to interface is better or CComContainedObjectEx
> <Interface> as class member is ?

Most likely, you want CComPtr<IOtherInterface>. You definitely don't want CComContainedObjectEx here.
--
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

0 new messages