Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top