要用UNICODE方式编译
CString m="11212";
string kkkkkk;
 kkkkkk=m;
G:\baseinfo\BaseinfoCtl.cpp(639) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
Error executing cl.exe.

解决方案 »

  1.   

    这个比较简单……kkkkkk = (const char*)m;CString里面有一个operator const char*,而string又有一个operator =(const char*)这样就可以了……
      

  2.   

    不像楼上说的那么简单,UNICODE时CString为WideString
    这样可以:
    CString m="11212";
    char buff[100];
    WideCharToMultiByte(CP_ACP, 0, m, -1, buff, 100, NULL, NULL);string kkkkkk;
     kkkkkk=buff;
      

  3.   

    居然考虑了Unicode……既然这样的话,干脆也不要用string了,直接用wstring好了……
      

  4.   

    CString cstr = "asd";
     std::string sstr = (LPCTSTR)cstr;
    ----------------------------------------------------------------我还没用过wstring呢,要用哪个头文件吗?谢谢
      

  5.   

    typedef std::basic_string<TCHAR> String;
    CString cstr = "asd";
    String sstr = (LPCTSTR)cstr;
    这样就UNICODE了.