Re: How to pass a reference to a CComBSTR
- From: "Egbert Nierop \(MVP for IIS\)" <egbert_nierop@xxxxxxxxxxxxxx>
- Date: Sun, 31 Jul 2005 11:03:00 +0200
"Heinz Ozwirk" <hozwirk.SPAM@xxxxxxxx> wrote in message news:42ec8069$0$29078$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"Steve Franks" <please@xxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag news:_t6dnYV4EPK_V3bfRVn-qg@xxxxxxxxxxxxxxI have a CComBSTR variable in function A. I want to pass this variable to function B by REFERENCE, so that function B can update this variable with a new string it calculates.
I'm passing in my CComBSTR like this: myfunction(& myCComBSTRvar) and myfunction looks like this: void myfunction(CComBSTR *myCComBSTRvarToUpdate) {}
This is not passing by reference - you are passing pointers. To pass by reference yous should declare myfunction as
void myfunction(CComBSTR& myModifiableVariable)...
and call it like
myfunction(myCComBSTRvar);
Some wise guy at MS thought it to be a good idea to overload operator& to make a CComBSTR easyly mix with plain BSTR. But by doing that he made it impossible to get the address of a CComBSTR itself. If you only use CComBSTR as a wrapper for BSTR, you should have a look at _bstr_t.
To my best knowledge, the solution would be using the m_str itself.
.
- Follow-Ups:
- Re: How to pass a reference to a CComBSTR
- From: Steve Franks
- Re: How to pass a reference to a CComBSTR
- References:
- How to pass a reference to a CComBSTR
- From: Steve Franks
- Re: How to pass a reference to a CComBSTR
- From: Heinz Ozwirk
- How to pass a reference to a CComBSTR
- Prev by Date: Re: How to pass a reference to a CComBSTR
- Next by Date: Re: Improved CComBSTR
- Previous by thread: Re: How to pass a reference to a CComBSTR
- Next by thread: Re: How to pass a reference to a CComBSTR
- Index(es):
Relevant Pages
|
Loading