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 :-)