我正在尝试在 C++ 中实现通用包装器,它将能够比较两件事。我已经这样做了:
template <class T>
class GameNode {
public:
//constructor
GameNode( T value )
: myValue( value )
{ }
//return this node's value
T getValue() {
return myValue;
}
//ABSTRACT
//overload greater than operator for comparison of GameNodes
virtual bool operator>( const GameNode<T> other ) = 0;
//ABSTRACT
//overload less than operator for comparison of GameNodes
virtual bool operator<( const GameNode<T> other ) = 0;
private:
//value to hold in this node
T myValue;
};
似乎我不能以这种方式重载 '<' 和 '>' 运算符,所以我想知道我能做些什么来解决这个问题。