I just want to know what does the below mentioned function means?

void swap(char& a, char& b)

Recommended Answers

All 2 Replies

It should exchange the value of the two variable parameters. The two parameters are passed by reference so that swap() can change them and the calling function will see the change.

Most likely its raw definition will be something like this :

void swap(char& a, char& b)
{
   char temp = a;
    a = b;
    b = temp;
}

Think of whats happening.

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.