建立了一个支持MFC的ATL工程,理所当然的也应该支持MFC,有这么一段代码
CString m_TempStr;
...
...
if(m_TempStr.Find("abcd")==0)
{
........
........
}
我觉的这段代码是完全没有问题的,而且一开始编译也可以通过,可是后来在if(m_TempStr.Find("abcd")==0)这一行就莫名其妙的出来error C2664: 'int __thiscall CString::Find(unsigned short) const' : cannot convert parameter 1 from 'char [5]' to 'unsigned short' This conversion requires a reinterpret_cast, a C-style cast or function-style cast这样的错误,类似的错误还有m_TempStr.Format("%s%.6f\n", "Xr: ", m_dWest);错误是error C2664: 'void __cdecl CString::Format(const unsigned short *,...)' : cannot convert parameter 1 from 'char [8]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast,函数atoi(),,错误是error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called,大家帮帮忙,多谢了

解决方案 »

  1.   

    你可以查msdn里面相应的函数,好像全部是因为你给的参数不对造成的。
    format好像只有两个参数,atoi好像是有三个吧!
      

  2.   

    改编译选项,
    去_UNICODE,不使用unicode编译或者if(m_TempStr.Find(L"abcd")==0)if(m_TempStr.Find(_T("abcd"))==0)
      

  3.   

    同意 zoid() 
    cannot convert parameter 1 from 'char [5]' to 'unsigned short' 其实就是提示使用了unicode 编码,
    那就使用(L"abcd")吧
      

  4.   

    CString temp="abcd"
    m_TempStr.Find(temp)试试.