我正在尝试用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;
};
Run Code Online (Sandbox Code Playgroud)
似乎我不能以这种方式超载'<'和'>'运算符,所以我想知道我能做些什么来解决这个问题.
我正在尝试提高算法的速度,在查看了正在调用哪些操作之后,我很难准确地确定是什么导致速度变慢。我想知道 Python 的 deepcopy() 是否可能是罪魁祸首,或者我是否应该进一步研究我自己的代码。