I am new to C++ so please bear with me. I know that _bstr_t
is just a wrapper class for BSTR
but, as seen in the MSDN documentation, _bstr_t
does not have an operator to convert itself to BSTR
.
So can I pass a _bstr_t
object to a function expecting a BSTR
as argument, and is it safe?
Or is there any better way to do this? I especially don't want any memory leaks with this.
I have seen numerous articles so just got confused about this. Sorry if it is a trivial question.
Yes and no.
BSTR
is defined to be equivalent towchar_t*
in the "afx.h" header file:And the
_bstr_t
class (in "comutil.h") does have conversion operators for that, with or without aconst
qualifier, as in:EDIT: But one minor 'note of caution' from the documentation for those operators: