if same function is to be done in two classes, then it should be better to make a friend function which performs the same task required in both classes.
The same function can not do the same task in two classes in C++ if the classes do not belong to one class hierarchy.
It is possible only when the function deals with two classes simultaneously. In this case it is declared as a friend function for both classes.
Two classes have different members. So any one function can not do the same task for different classes. It need to have access to members of the both classes simultaneously and explicitly specify their names..