A nonmember function cannot directly access private members of a class unless the class grants it permission by declaring it to be a friend function. This is done by putting the function's prototype inside the class declaration and preceding it (but not its definition) by the keyword friend.