Well, I don't want to do lot of copy-paste in my code, so, I'm just wondering - is it possible to have two different names of one functions(I prefer that function name describe what is used for):

ex:

int do_my_client(int info)
{
 blah blah blah;
 ....
 ....
 return inf;
}


int main()
{
  client = do_my_client(55); // a call to function do_my_client
  server = do_my_server(66); // same call, but with different name to function do_my_client
 return 0;
}

maybe is there a way like with cases:

Switch(a){
case 5 : case 6 : case 7 : cout << "the same text in 3 different switches";
}

so sth like that:????

int do_my_client=int do_my_server(int info) {
..........
}

or I should try sth like this:

typedef do_my_client do_my_server;

I don't get that, do you mean the following: Is it possible to call a certain function using two different names ?
e.g:

int a = 5, b = 6;

//makeSum and addition do exactly the same

int c = makeSum(a,b);
int d = addition(a,b);

Do you mean something like this?

>>is it possible to have two different names of one functions

Short answer: no

However, what you could do is put all the common code into a single function which is called by the other two functions

int common_code(int info)
{
   // blabla
}

int do_my_server(int info)
{
    common_code(info);
}

int do_my_client(int info)
{
    common_code(info);
}

Implicitly you can say that it's possible using the work-around Ancient Dragon provided you with :) ...

void name() { std::cout << "It's me, Xamas\n"; }
inline void anothername() { name(); }
void ((*yetanothername)()) = name;
void tryThis()
{
    name();
    anothername();
    yetanothername();
}

;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.