Swap fails in case of int and works in case of string?

Swap(str1, str2) works because of Argument dependent lookup.

Swap(str1, str2) works because of Argument dependent lookup P. S: Pitfalls of ADL.

You're not qualifying swap; it works when passing in std::string objects because of ADL, but as int does not reside in namespace std you must fully qualify the call: std::swap(x, y); or use a using declaration: using std::swap; swap(x, y).

Strings are in the std:: namespace, so the compiler looks for swap() for strings there. Ints are not, so it doesn't. You want: std::swap(x,y).

In both cases you should be using std::swap() instead of swap().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions