I'm getting "error C2039: 'AllocSysString' : is not a member of 'System::Char' error.

I'm trying to assign the result to a string variable.

 wchar_t str;
 return str.AllocSysString();

But I'm getting the above error.

Recommended Answers

All 3 Replies

So how should I solve this? sorry I'm new to C++.

Actually AllocSysString() returns a BSTR but it's a member of CString. Change the wchar_t to Cstring:

 Cstring str;
 return str.AllocSysString();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.