【发布时间】:2012-10-25 20:47:25
【问题描述】:
这真的让我很烦。我正在重载 C++ 中的比较运算符,但遇到了一个奇怪的错误,我不知道如何纠正。
我正在使用的代码如下所示:
bool HugeInt::operator==(const HugeInt& h) const{
return h.integer == this->integer;
}
bool HugeInt::operator!=(const HugeInt& h) const{
return !(this == h);
}
其中integer 是short [30]
== 重载工作正常。但是当我尝试在!= 正文中使用它时,它告诉我== 尚未定义。我是 C++ 新手,欢迎提供任何提示。
谢谢!
【问题讨论】:
-
看看这个类似的SO线程stackoverflow.com/questions/1947971/…