编译器错误 C2662
来源:互联网 发布:专业手机维修软件 编辑:程序博客网 时间:2024/06/06 12:52
编译器错误 C2662
Visual Studio 2005
其他版本
错误消息
“function”: 不能将“this”指针从“type1”转换为“type2”编译器不能将 this 指针从 type1 转换为 type2。
此错误可能是由对 const 对象调用非 const 成员函数引起的。可能的解决方案:
从对象声明中移除 const。
将 const 添加到成员函数中。
下面的示例生成 C2662:
// C2662.cppclass C {public: void func1(); void func2() const{}} const c;int main() { c.func1(); // C2662 c.func2(); // OK}
在使用 /clr 编译时,不能对 const 或 volatile 限定托管类型调用函数。由于不能声明托管类的常量成员函数,因此不能调用常量托管对象上的方法。
// C2662_b.cpp// compile with: /c /clrref struct M { property M^ Type { M^ get() { return this; } } void operator=(const M %m) { M ^ prop = m.Type; // C2662 }};ref struct N { property N^ Type { N^ get() { return this; } } void operator=(N % n) { N ^ prop = n.Type; // OK }};
下面的示例生成 C2662:
// C2662_c.cpp// compile with: /c// C2662 expectedtypedef int ISXVD;typedef unsigned char BYTE;class LXBASE {protected: BYTE *m_rgb;};class LXISXVD:LXBASE {public: // Delete the following line to resolve. ISXVD *PMin() { return (ISXVD *)m_rgb; } ISXVD *PMin2() const { return (ISXVD *)m_rgb; }; // OK};void F(const LXISXVD *plxisxvd, int iDim) { ISXVD isxvd; // Delete the following line to resolve. isxvd = plxisxvd->PMin()[iDim]; isxvd = plxisxvd->PMin2()[iDim]; }
0 0
- 编译器错误 C2662
- C2662编译错误
- error C2662
- Error C2662
- 编译器错误:CS0426
- 内存条与编译器错误
- VC6编译器错误汇总
- VC 编译器错误大全
- 编译器错误 CS0445
- 编译器错误消息: CS0433
- 编译器错误 C2511
- Vs2005编译器错误
- java 编译器版本错误
- ActionScript 3.0 编译器错误
- 编译器错误消息: CS0016
- 编译器错误 error CS0120
- 编译器错误 C2894
- c++ 编译器 错误解决方法
- 西川善司的3D图形技术概念和渲染管线的处理
- Constant Member Functions
- Android Surfaceflinger源码分析
- 判断iOS设备类型
- C++回顾之static用法总结、对象的存储,作用域与生存期
- 编译器错误 C2662
- 代码库开源项目推荐(1.3)
- Linux下设置Oracle开机自启动
- adnroid 短信 发送
- Qt中QTableWidget用法总结
- java设计模式学习笔记2 策略模式
- ios学习之App States
- 开源项目推荐(12.25):菜单(Menu)
- C++中相对路径与绝对路径以及斜杠与反斜杠的区别