Ryo
Ryo

Reputation: 1035

What is the meaning of _bstr_t::operator=?

I have some source code with COM string manipulation but have this code is make me confused

_bstr_t btLeft;
_bstr_t tempData ;
_bstr_t btRight ;
//Do something to assign values to 3 above variables 
.....
//And here
_bstr_t::operator = (btLeft + tempData + btRight); //confused!!!

return true

=> What is the meaning of this code?

_bstr_t::operator = (btLeft + tempData + btRight);

it's look like string concanate? which is returned value?

Upvotes: 0

Views: 112

Answers (1)

Lukas-T
Lukas-T

Reputation: 11340

It's the same as the following:

const auto foo = btLeft + tempData + btRight;
this->_bstr_t::operator=(foo);
  1. btLeft + tempData + btRight adds together the three instances of _bstr_t (see the documentation here). This does indeed concatenate the 3 strings.
  2. this->_bstr_t::operator=(foo); takes the result of 1 and invokes the assignment operator (see also the documentation) of the base class which must be _bstr_t.

You could say it concatenates three strings and assigns the result to itself.

(All of this is under the assumption that Hasn Passant's crystal ball told him correctly, that your code is part of a member function of a class that inherits from _bstr_t)

Upvotes: 1

Related Questions