As in C++,
friend specifier may only be used within the specification of a class.
It may only be used in the declaration of a function or a class.
friend specifier says that the function or class named in the
declaration has access to the private members of the class in which it occurs.
(This is automatic if you use annotations to a header file for your
For example, one could put the declaration
friend ostream& operator<<(ostream&, date);
in the class
date to say that this overloading of the
C++ "put to" operator is to have access to the private members of the class
Such a declaration is implemented by a matching definition in the header
file where the declaration of class
See section 7.12 Specifying Friends for a discussion of when to grant friendship.
Go to the first, previous, next, last section, table of contents.