0
在我的课堂我有成员函数:错误c6277用C重载&& ++
const bool operator&&(const KinematicVariable &right) const {
return this->isUsed() && right.isUsed();
}
inline const bool isUsed() const { return this->_used; }
然后我尝试
if (k1 && k2 && k3)
,但我得到
error: C2677: binary '&&' : no global operator found which takes type
'KinematicVariable' (or there is no acceptable conversion)
这是在'KinematicVariable'类中吗?你必须有一个for(bool,const KinematicVariable&),因为第一次调用返回一个布尔值以供第二次使用。 – chris 2013-03-03 17:35:12
是的,就在标题内。 – y2k 2013-03-03 17:35:28
仅供参考,重载'&&'或'||'是[认为不好的做法](http://stackoverflow.com/questions/5133114/overloading-logical-operators-considered-bad-practice)。 – 2013-03-03 17:35:51