作者ric2k1 (Ric)
標題[轉錄]講義有一個地方不知道是不是錯了
時間Sat Oct 18 01:23:31 2008
※ [本文轉錄自 ric2k1 信箱]
老師,您的講義Topic3的第47張投影片,有一段話
However, in a single prototype, a particular
identifier can be used only once
是說function prototype不能像是
void a(int a, int a)嗎?
不過我測試了一下我的devc++
這樣可以compile過且正常執行
如下:
#include<iostream>
using namespace std;
void a(int a, int a);
int main(void){
a(1,2);
system("pause");
}
void a(int a, int b){
cout << a << endl;
cout << b << endl;
}
--
※ 編輯: ric2k1 來自: 59.121.131.48 (10/18 01:24)
1F:→ ric2k1:嗯, 我在 Linux 上測試也可以, 所以這個故事告訴我們 10/18 01:25
2F:→ ric2k1:在 function prototype 上的變數名字是沒有用的, 會被忽略 10/18 01:25
3F:→ ric2k1:但是如果你將下面那個 function 也改成 a(int a, int a) 10/18 01:26
4F:→ ric2k1:compile 就不會過了,會 complain redeclaration of `int a' 10/18 01:27
5F:→ ric2k1:我以後會注意稍做修正. 10/18 01:28