Question

The ATL class CComBSTR has a BSTR member m_str and an operator BSTR () which returns m_str.

Now, if a function takes a BSTR * as argument, is it ok to pass the address of a CComBSTR?

CComBSTR path;
// signature is IzFileFinder::GetDir(CY index, LPBSTR path)
fileFinder->GetDir(INT64toCURRENCY(i), &path);

The compiler doesn't complain, but if it really is ok, why does it work?

Était-ce utile?

La solution

You are not passing an address of CComBSTR, but an address of its m_str member. CComBSTR happens to provide, among other things, an operator&() that returns &m_str.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top