#include <iostream>
using namespace std;
template < class T >
void swap (T& a, T& b)
{
T temp = a;
a = b;
b = temp;
}
int main()
{
char a = 'a';
char b = 'b';
swap (a, b);
cout << "a = " << a << endl;
cout << "b = " << b << endl;
return 0;
}
该代码不能在linux下编译KDE命令行(gcc编译器)。 但是,如果我改变“使用名称空间标准”到“使用std :: cout;使用std :: cin使用std :: endl”程序可以编译和运行良好。它出什么问题了? 非常感谢您无法编译
你得到了什么*确切*错误信息? – 2012-03-11 16:24:43
也许如果你提到它为什么“不能编译”?像...错误信息?我们不是千里眼。 – 2012-03-11 16:24:45
只需使用** std :: cout **而不是** cout **,同样当您使用**使用命名空间标准** – DumbCoder 2012-03-11 16:25:19