Class Template: Friends

In this lesson, we will learn about friends of class templates.

Friends of a class template have access to all members of the class template

A class or a class template can have a friendship three features: to class or class templates, to function or function templates, and to types.


  1. The declaration of friends can be made in an arbitrary place in the class declaration.
  2. The access rights in the class have no influence.
  3. Friendship will not be inherited.
  4. Friendship is not transitive.

Note: A friend has unrestricted access to the members of the class.

Get hands-on with 1000+ tech skills courses.