我已经定义了一个模板容器Tree<T>
,有两个成员类迭代器:const_iterator
和iterator
现在我想添加非成员比较运算符:
template<typename T>
bool operator==(Tree<T>::const_iterator a, Tree<T>::iterator b)
{
return a.ptr() == b.ptr();
}
但我有编译错误:
declaration of 'operator==' as non-function
为什么?这是因为模板吗?