Let us consider a situation where we have a class called ‘length’ which represents the length of an item (say cloth) in feet and inches. Its class diagram is shown in Fig. 9.1.
Figure 9.1 A class called ‘length’
Now if we desire to add two objects of this class type, one of the options is to use a friend function (say add()) as shown below:
The following main() function tests the above given class.
A sample ...