operator==中&&与||优先级不规范,导致提交warning,改正如下:

template<class T>bool operator==(T A) {
         bigint other(A);
         // 重点在这里:给 || 左边的两个 && 条件加上了外层括号 (...)
         if ( (other._a == this->_a && other.symbol == this->symbol) || 
              (this->size() == 1 && this->symbol == -1 && other.symbol == 1 && other.size() == 1 && (*this)[0] == 0 && other[0] == 0) )
             return 1;
         return 0;
     }

1 条评论

  • 1