#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