4.
// std::ofstream ofile;
ofile<<std::string(str);
error C2440: '<function-style-cast>' : cannot convert from 'CString' to 'std::string'
No constructor could take the source type, or constructor overload resolution was ambiguous5.
string str1(str);
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::allocator<_Ty> &)' : cannot convert parameter 1 from 'CString' to 'const std::allocator<_Ty> &'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>,
_Ty=char
]
and
[
_Ty=char
]
Reason: cannot convert from 'CString' to 'const std::allocator<_Ty>'
with
[
_Ty=char
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called6.
// std::ofstream ofile;
ofile<<std::string(str);
error C2440: '<function-style-cast>' : cannot convert from 'CString' to 'std::string'
No constructor could take the source type, or constructor overload resolution was ambiguous5.
string str1(str);
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::allocator<_Ty> &)' : cannot convert parameter 1 from 'CString' to 'const std::allocator<_Ty> &'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>,
_Ty=char
]
and
[
_Ty=char
]
Reason: cannot convert from 'CString' to 'const std::allocator<_Ty>'
with
[
_Ty=char
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called6.
解决方案 »
- 怎么以管理员身份开打程序?
- 使用DirectShow预览并捕捉5秒钟的AVI文件,预览可以,但捕捉到的AVI文件提示打不开,同一台机子AMCAP捕捉的AVI文件没问题,疑惑
- 做数据库软件,VC是最好的选择吗?
- OCX控件上想添加一个工具栏要怎么做?
- 请教锁屏的问题
- 用 VC 怎么连接 DB2, 不安装 DB2 客户端程序,都需要那些 DLL 文件,这个问题问了,这么多天了,难道没人会吗,难道大家都不用 DB2 吗????
- 寻VC++高手合作!!!
- 关于CListView的使用和应用!
- 因为项目组要求用4空格代替tab,很不开心
- 象SHGetDiskFreeSpace 这样带有SH开头的函数 是什么函数啊!!
- 高手:对话框如何响应SW_SHOW消息??
- 如何在DOC文档类中延时....
if(pdf.begin_document(filename.GetBuffer(0),_T("")) == -1)
error C2664: 'PDFlib::begin_document' : cannot convert parameter 1 from 'wchar_t *' to 'std::string'
No constructor could take the source type, or constructor overload resolution was ambiguous
typedef basic_string<char, char_traits<char>, allocator<char> >
string;
typedef basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> > wstring;string 是用于非unicode的,而wstring是用于unicode的。所以这里就不能用统一的代码写了。建议函数参数使用TCHAR *.
这个可能是因为wchar_t*和std::string之间没有提供转化函数所导致。