As mentioned in Chapter 4, you should declare your class's data members private, so that they're inaccessible to functions outside of the class. This lets you change the implementation of a class without affecting the programs that use the class.
Sometimes, however, you may find that two or more classes must work together very closely—so closely that it's inefficient for them to use each other's access functions. You may want one class to have direct access to another class's private data. You can permit this by using the friend keyword.