I recently came across a piece of C ++ code where the class became a friend to myself. Since I read in various forums, the class is already a friend to myself. Therefore, I was wondering if there was any specific reason why a person would like to make a familiar class clearly.
Another question: what is the reason to make the class your friend?
Perhaps someone with more experience can clarify this topic.
Here is a sample code to illustrate my question:
template < typename T> class Foo: public T { protected: template < typename U> friend class Foo; }
source share