how to overload operator == outside template class using friend function?

前端 未结 4 1602
轻奢々
轻奢々 2021-01-15 16:00

I\'m trying to write a template class which overloads operator==. I know how to get it inside the class:

    template 
            


        
4条回答
  •  粉色の甜心
    2021-01-15 16:19

    You have to put friend classes within each other, as well as in themselves. The Real one is named syntactically the same without replacing expressions. So friend bool operator==(P,P); goes in both of the classes. So put friend before bool in the class T :-)

提交回复
热议问题