c++重载错误:有相似的转换
时间:2010-07-17
来源:互联网
本帖最后由 lishizelibin 于 2010-07-17 15:32 编辑
头文件中
friend FIRSTDLL_EXPORT OdString operator+(const OdString& string1, const OdString& string2);
friend FIRSTDLL_EXPORT OdString operator+(const OdString& string, OdChar ch);
friend FIRSTDLL_EXPORT OdString operator+(OdChar ch, const OdString& string);
friend FIRSTDLL_EXPORT OdString operator+(const OdString& string1, const OdChar* string2);
friend FIRSTDLL_EXPORT OdString operator+(const OdChar* string1, const OdString& string2);
实现文件中
OdString strSheetName = strSeed + DD_T('-') + strLayoutName; //该句出现错误
strSeed 和 strLayoutName 都是OdString类型
#define DD_T(x) __DD_T(x)
#define __DD_T(x) L ## x
error C2666: “operator +”: 4 个重载有相似的转换
4> 可能是“OdString operator +(const OdString &,OdChar)”[通过使用参数相关的查找找到]
4> 或“内置 C++ operator+(OdChar, wchar_t)”
4> 或“内置 C++ operator+(const wchar_t *, wchar_t)”
4> 或“内置 C++ operator+(const char *, wchar_t)”
4> 试图匹配参数列表“(OdString, wchar_t)”时
运行环境:VS2005
头文件中
friend FIRSTDLL_EXPORT OdString operator+(const OdString& string1, const OdString& string2);
friend FIRSTDLL_EXPORT OdString operator+(const OdString& string, OdChar ch);
friend FIRSTDLL_EXPORT OdString operator+(OdChar ch, const OdString& string);
friend FIRSTDLL_EXPORT OdString operator+(const OdString& string1, const OdChar* string2);
friend FIRSTDLL_EXPORT OdString operator+(const OdChar* string1, const OdString& string2);
实现文件中
OdString strSheetName = strSeed + DD_T('-') + strLayoutName; //该句出现错误
strSeed 和 strLayoutName 都是OdString类型
#define DD_T(x) __DD_T(x)
#define __DD_T(x) L ## x
error C2666: “operator +”: 4 个重载有相似的转换
4> 可能是“OdString operator +(const OdString &,OdChar)”[通过使用参数相关的查找找到]
4> 或“内置 C++ operator+(OdChar, wchar_t)”
4> 或“内置 C++ operator+(const wchar_t *, wchar_t)”
4> 或“内置 C++ operator+(const char *, wchar_t)”
4> 试图匹配参数列表“(OdString, wchar_t)”时
运行环境:VS2005
作者: lishizelibin 发布时间: 2010-07-17
没有直接的 OdString + wchar_t ,于是编译器发现wchar_t可以转化为OdChar,以适应OdString+OdChar这个重载;
也可以将OdString转化为OdChar,以适应OdChar+wchar_t这个重载;
……
也可以将OdString转化为OdChar,以适应OdChar+wchar_t这个重载;
……
作者: bruceteen 发布时间: 2010-07-17
谢谢楼上,我也是刚刚发现,然后强制转化为了OdChar,能看看我的另一帖么?
作者: lishizelibin 发布时间: 2010-07-17
作者: lishizelibin 发布时间: 2010-07-17
感觉应该转化为const OdChar *
作者: lishizelibin 发布时间: 2010-07-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28