#include <iostream>
#include <string>
#include <algorithm>
int main()
{
std::string str1 = "good", str2 = "luck";
swap(str1,str2); /*Line A*/
int x = 5, y= 3;
swap(x,y); /*Line B*/
}
If I comment Line B the code compiles(http://www.ideone.com/hbHwf) whereas commenting Line A the code fails to compile(http://www.ideone.com/odHka) and I get the following error:
error: ‘swap’ was not declared in this scope
Why don't I get any error in the first case?