看板 Programming 關於我們 聯絡資訊
第一題的程式碼 #include <iostream> #include <cstdlib> using namespace std; template <class T> void swap1(T& x, T& y) { T temp; temp=x; x=y; y=temp; } int main(void) { int a=5,b=8; double c=1.25,d=6.64; swap1(a,b); swap1(c,d); cout<<a<<" "<<b<<endl; cout<<c<<" "<<d<<endl; system("pause"); return 0; } 函數名稱竟然不能用swap會有錯誤,是編譯器有內定了? 害我卡了好久 改成swap1竟然就可以了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.167.105.145
jtmh:有錯誤,那錯讓訊息是?218.175.150.249 04/05 11:52
yauhh:如果有內定,錯誤訊息應該會講ambiguous 61.231.64.117 04/05 12:09