lapucca
asked on
Do I need to resize wstring if it already has a string but I'm assigning a new string with different size?
The following variables are all wstring. However, those in userDataIter(vector Iterator) points to already has a string them. Would the code below be correct as far as the memory goes for wstring? Thank you.
if(!(userData->LoginName.e mpty())&& (LoginNameChanged))
{
userDataIter->LoginName.cl ear();
userDataIter->LoginName = userData->LoginName;
}
if(!(userData->shell.empty ())&& (shellChanged))
{
userDataIter->shell.clear( );
userDataIter->shell = userData->shell;
if(!(userData->LoginName.e
{
userDataIter->LoginName.cl
userDataIter->LoginName = userData->LoginName;
}
if(!(userData->shell.empty
{
userDataIter->shell.clear(
userDataIter->shell = userData->shell;
If you're talking about a 'std::wstring' - no, not at all. The string object itself will take care about that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
???
You asked whether you need to resiue a string - I answered 'No'. Is that incoorect? No, it isn't... So I cannot quite understand on which basis you are picking your answers.
You asked whether you need to resiue a string - I answered 'No'. Is that incoorect? No, it isn't... So I cannot quite understand on which basis you are picking your answers.
ASKER
Hi jkr,
Your answer is correct and was posted an hour earlier. I should have accept your answer instead. I picked rajeev's answer becuase he also point out the other question I meant to ask, do I need to clear the string firs (_bstr_t requires detach first).
Anyway, you're still correct. I'll pick my answer more carefully next time based on my question. Thank you.
Your answer is correct and was posted an hour earlier. I should have accept your answer instead. I picked rajeev's answer becuase he also point out the other question I meant to ask, do I need to clear the string firs (_bstr_t requires detach first).
Anyway, you're still correct. I'll pick my answer more carefully next time based on my question. Thank you.