作者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