pTBData->set_sTestTime(CTime::GetCurrentTime().Format( "%A, %B %d, %Y" ));//  《---  这句出错,我要把CString的当前时间转化为string类型的变量保存。  错误为:
E:\TestBed\DataAcquisitionDlg.cpp(325) : error C2664: 'set_sTestTime' : cannot convert parameter 1 from 'class CString' to 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
  另外,string的当前时间再转化CString类呢?

解决方案 »

  1.   

    CString cs;
    string s;....
    cs = s.c_str();....
    s = (LPCTSTR)cs;
      

  2.   

    to truewill(无处不在):您只说了A——>B, 那么 B——>A呢?把CString的转化为string类型怎么转化?
      

  3.   

    CString strA = "A";
    std::string strB = "B";strA = strB.data();  // CString -> string
    strB = LPCSTR(strA);
      

  4.   

    CString strA = "A";
    std::string strB = "B";strA = strB.data();  // CString -> string
    strB = LPCSTR(strA); // string -> CString