I\'m trying to write a template class which overloads operator==. I know how to get it inside the class:
template
This is a tricky issue: the friend declaration in the class will define a different friend function for each instantiation of your class. In other words, Point
and Point
will give rise to 2 different non-template friend functions. On the other hand, the outside function is a template function, not related to the friend
inside the class. Solution: define the friend function inside the class. Due to friend name injection, it will be found successfully by ADL.