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?
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