为何编译器会报找不到函数定义的错误呢?即使说两个<可能与左移位符冲突,但是改为<=也是一样报错说找不到函数定义,如果是>则不会报错,这其中是什么原因呢?
#include <iostream>
#include <string>
using namespace std;
template<typename T> class test;
template<typename T>
bool operator < (const test<T>& t1, const test<T>& t2) {
return t1.t < t2.t;
}
template<typename T>
class test {
friend bool operator < <T>(const test<T>& t1, const test<T>& t2);
public:
test(const T& t):t(t){}
private:
T t;
};
int main()
{
test<int> t1(1), t2(2);
cout << (t1 < t2);
}