在内联函数中调用外部函数

Calling outside functions in inline functions

假设我有内联函数:

// equality operator where left operand is a long
inline bool operator==(long num, BigInt const& val) {
    return compare(num, val) == 0;
}

where 'compare'定义在BigInt.h内联函数所在的位置。我如何使用比较或者我什至可以使用它?

BigInt.h

class BigInt {

public:

//code

int BigInt::compare(long num, BigInt const& other) const;

//code

};

// equality operator where left operand is a long
inline bool operator==(long num, BigInt const& val) {
    return compare(num, val) == 0;
}

compare是一个成员函数,你应该把它改成

// equality operator where left operand is a long
inline bool operator==(long num, BigInt const& val) {
    return val.compare(num, val) == 0;
}

而且我仍然怀疑为什么 compare 是一个成员函数。如果它与当前对象无关,它应该只是一个普通函数或静态成员函数。