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?

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top