【发布时间】:2011-06-01 16:35:23
【问题描述】:
#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*/
}
如果我评论 B 行代码编译 (http://www.ideone.com/hbHwf) 而评论 A 行代码无法编译 (http://www.ideone.com/odHka) 我得到以下错误:
error: ‘swap’ was not declared in this scope
为什么我在第一种情况下没有收到任何错误?
【问题讨论】: