A friend function has access to the private members of that class just as a member function does. A friend function can directly read the value of a member variable and can even directly change the value of a member variable.
You make a function a friend of a class by listing the function declaration in the definition of the class and placing the keyword friend in front of the function declaration.
The only reason to make a function a friend is to make the definition of the function simpler and more efficient.
The friend function declaration may be placed in either the private or public section but it will be a public function in either case, so it is clearer to list it in the public section.
A friend function is not a member function. A friend function is defined and called the same way as an ordinary function. You do not use the dot operator in a call to a friend function and you do not use the type qualifier in the definition of a function function.
A simple rule to help you decide between member functions and nonmember functions is:
1. Use a member function if the task being performed by the function involves only one object.
2. Use a nonmember function if the task being performed involves more than one object.
A destructor is a member function that is called automatically when an object of the class passes out of scope.
You might want your destructor to perform some other cleanup details but returning memory to the freestore is the main job of the destructor.
A destructor always has the same name as the class it is a member of but the destructor has the tilde symbol, ~, at the beginning of its name.
A destructor has no parameters and no type for the value returned, not even void.
A class can only have one destructor, you cannot overload the destructor for the class. A destructor is defined just like any other member function.