Please bear with me, i have been a c++ programmer for a little while.
I need to know if i am doing this wrong. It works, but i suspect it causes a memory leak. I have this function:
_bstr_t WCH2BSTR(wchar_t* st)
{
BSTR stres = SysAllocString(st);
return (_bstr_t)stres;
}
Let's say i were to use the result like this:
wcout << WCH2BSTR(wCharArr) << " done." << endl;
Will this cause a memory leak, or will the BSTR be deleted by a "garbage collector" like in Java?
If it is a memory leak, how can i prevent it without losing the ability to do it as a one-liner? Sometimes the results of WCH2BSTR are stored in a BSTR variable and disposed of properly, but i would like to use the same function for concatenating wchar_t to BSTR's as well in a one-liner fashion.
Thanks.