泰国娱乐圈有中国人吗:c++的一个格式问题

来源:百度文库 编辑:高考问答 时间:2024/05/14 08:29:03
考试考过:
void swap(int ,int b)
void swap(int a,int )
void swap(int,int)
void swap(int a,intb)
哪一个是正确的呢?

最后一个正确。
void swap(int a,int b)

其他没有形式参数
void swap(int ?,int b)
void swap(int a,int ? )
void swap(int ,int )

在定义函数是都是可以的,不过在写函数时要用
void swap(int a,int b)

最好用
void swap(int a,int b)
比较规范的格式

最后一个比较规范

void swap(int a,int b) 正确
行参要写参数及类型

调用时
可以不写类型
如:
swap(a,b);

void swap(int a,int ) void swap(int a,intb)
都可以!