建立了一个支持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,大家帮帮忙,多谢了
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,大家帮帮忙,多谢了
解决方案 »
- 请教:关于文件的读取问题,在线等待!!!
- 急~~~~~~~~~:CString中的Mid怎么和wstring中的substr对应呀?
- vc++的问题
- 我写了一个IP修改程序,但是我修改不了DNS
- 请问用ATL做的ActiveX控件,如何获得容器比如Word的Application的指针?100分啊
- 如何查看控件的基类?
- 技术问题!急,up 有分~~~~~~~~~~~也想知道的帮我顶
- 如何把整形转化为字符型 在显示出来
- 指针出问题了!!
- 永远的API
- 为什么我调试一次后,再调试的时候总说cannot open xxxxx.exe for writing
- 高分问一个简单问题,只求马上解决!立即结!!
format好像只有两个参数,atoi好像是有三个吧!
去_UNICODE,不使用unicode编译或者if(m_TempStr.Find(L"abcd")==0)if(m_TempStr.Find(_T("abcd"))==0)
cannot convert parameter 1 from 'char [5]' to 'unsigned short' 其实就是提示使用了unicode 编码,
那就使用(L"abcd")吧
m_TempStr.Find(temp)试试.