1

我正在尝试定义函数 find from class FHhashQPwFind。你能告诉我我做错了什么吗?

我把评论“这是错误”放在编译器说的地方:

错误:模板参数的数量错误(1,应该是 2)

template <class Object, typename KeyType>
class FHhashQPwFind: public FHhashQP<Object>
{
public:
    const Object find(const KeyType & key);
protected:
        int myHashKey(const KeyType & key) const;
    int findPosKey( const KeyType & key ) const;
};
template <class Object, typename KeyType>
const Object FHhashQPwFind<Object>::find(const JeyType & key)//HERE IS THE ERROR
{

}
4

1 回答 1

1

我当然会尝试

const Object FHhashQPwFind<Object, KeyType>::find(const KeyType & key)

还要注意你在模板参数中命名它JeyType

错误是因为您的方法被声明为

 FHhashQPwFind<Object>

当它需要它的第二个参数 KeyType 时:

 FHhashQPwFind<Object, KeyType>

写方法的时候。

于 2013-11-13T04:32:23.940 回答