class MyString { public: MyString(const std::wstring& s2) { s = s2; } operator LPCWSTR() const { return s.c_str(); } pri
Generally speaking it's undefined behavior. According to this article Visual C++ just invokes the conversion from CString to a POD type to cover you - that is permissible implementation of undefined behavior.
CString