在VS2008下面编译通过的一套源码 在VC6下编译不过,报错如下:
error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'const class Oid' (or there is no acceptable conversion)
其中出错地方如下,这是头文件中一段:
DLLOPT friend int operator==(const Oid &lhs, const Oid &rhs);
DLLOPT friend int operator!=(const Oid &lhs, const Oid &rhs)
{ return (!(lhs == rhs)); };
DLLOPT friend int operator<(const Oid &lhs, const Oid &rhs);
DLLOPT friend int operator<=(const Oid &lhs, const Oid &rhs)
{ return ((lhs < rhs) || (lhs == rhs)); };
DLLOPT friend int operator>(const Oid &lhs, const Oid &rhs)
{ return (!(lhs <= rhs)); }; // just invert existing <=
DLLOPT friend int operator>=(const Oid &lhs, const Oid &rhs)
{ return (!(lhs < rhs)); }; // just invert existing <
DLLOPT friend int operator==(const Oid &lhs, const char *rhs);
DLLOPT friend int operator!=(const Oid &lhs, const char *rhs);
DLLOPT friend int operator<(const Oid &lhs, const char *rhs);
。比如我在第一个声明了“==”的重载 第一个声明“!=”时候调用了“==”的重载。按照我的理解我在调用前声明了,而且cpp中有实现,为什么还会报错,怎么样解决呢?
error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'const class Oid' (or there is no acceptable conversion)
其中出错地方如下,这是头文件中一段:
DLLOPT friend int operator==(const Oid &lhs, const Oid &rhs);
DLLOPT friend int operator!=(const Oid &lhs, const Oid &rhs)
{ return (!(lhs == rhs)); };
DLLOPT friend int operator<(const Oid &lhs, const Oid &rhs);
DLLOPT friend int operator<=(const Oid &lhs, const Oid &rhs)
{ return ((lhs < rhs) || (lhs == rhs)); };
DLLOPT friend int operator>(const Oid &lhs, const Oid &rhs)
{ return (!(lhs <= rhs)); }; // just invert existing <=
DLLOPT friend int operator>=(const Oid &lhs, const Oid &rhs)
{ return (!(lhs < rhs)); }; // just invert existing <
DLLOPT friend int operator==(const Oid &lhs, const char *rhs);
DLLOPT friend int operator!=(const Oid &lhs, const char *rhs);
DLLOPT friend int operator<(const Oid &lhs, const char *rhs);
。比如我在第一个声明了“==”的重载 第一个声明“!=”时候调用了“==”的重载。按照我的理解我在调用前声明了,而且cpp中有实现,为什么还会报错,怎么样解决呢?
解决方案 »
- RegisterHotKey注册的全局热键在WIN7无效
- 如何用MFC编写抓包程序(与Etherpeek类似)
- 关于消息映射宏ON_REGISTERED_MESSAGE的奇怪问题:
- c++ primer 的一个位操作。
- 为什么我的程序能通过编译但不能运行,Rebuild all后才能正常运行?
- 为什么有时候不能设中断点???
- 把一般DLL转成COM,求救?
- 请教#define IDC_EDIT1 WM_USER+1000 的问题!
- 关于CSplitterWnd.
- 在从一个对话框窗口切换到另一个窗口的时候的消息问题!
- WTL中如何把消息发送到ActiveX控件窗口
- 为什么每次heapfree的时候都说 其原因可能是堆被损坏??
貌似得去掉const?