I don't know how to change wstring value in struct . I don't know where is my error. do you help me ?
I can't understand why string value change success, wstring value change failed .
struct TestStruct{
string falg1;
wstring falg2;
TestStruct setFlag1(string str ) {
falg1 = str;
return *this;
}
TestStruct setFlag2(wstring str ) {
falg2 = str;
return *this;
}
};
int main(int argc,
char ** argv) {
TestStruct testStruct;
testStruct.setFlag1("string")
.setFlag2(L"Wstring");
wcout << "string length:" << testStruct.falg1.size() << endl;
wcout << "Wstring content:" << '[' << testStruct.falg2 << ']' << endl;
wcout << "Wstring length:" << '[' << testStruct.falg2.size() << ']' << endl;
}
The output content is :
string length:6
Wstring content:[]
Wstring length:[0]