c++错误 binary '=' : no operator defined which takes a right-hand operand of type 'class CStri

来源:百度知道 编辑:UC知道 时间:2024/09/25 22:21:54
E:\Program Files\Microsoft Visual Studio\MyProjects\people\peopleView.cpp(190) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
E:\Program Files\Microsoft Visual Studio\MyProjects\people\peopleView.cpp(195) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
E:\Program Files\Microsoft Visual Studio\MyProjects\people\peopleView.cpp(203) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
E:\Program Files\Microsoft Visual Studio\MyProjects\people\peopleView.cpp(209) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class C

你是在拿CString的值向string或者char*之类的地方赋值吧?
CString向这些类型转化的时候,要使用CT2A()这个宏
比如
CString cs;
string s;
s = cs;//这样是错误的
s = CT2A(cs);//要这样用

可能是不能直接使用‘=’,你可能需要重载‘=’