1) Derive the other classes from c1. The other classes will inherit f() as well as any data members which appear in the function f().
2) Include an instance of c1 as a member of the other classes.
3) Pass a c1 object as an argument to the other classes functions.
4) Use a c1 object as a local variable in the other classes functions.
Whether any of those options are sensible depends entirely upon the problem at hand.
These are the common ways to include the items of a class in another class. But Is there any way in order to include only one member function of a class without including whole the class by instancing one of its object. I mean is there any way to use "friend" or "virtual" functions just to link the two classes in this matter??
If the function is general enough to be in multiple classes, why is it in a specific class to begin with? Either move it out or make it static (if you really want it to be related to that class)
Ok. It is a very good hint. I may find my way to exclude this function or make it static. Now for "static" case, only declaring the base function with identifier "static" is enough?
class c1
{
public:
static void f() { // body of the function // };
};