c. 在外部定义前加上关键字static,使它为文件链接性为内部的静态变量,也可以在未命名的命名空间中定义。
d. 在该函数中声明为static int beencalled;,使它为本地静态变量。
2 using 声明使得名称空间中单个名称可用,而using编译指令使得名称空间中所有得名称都可用。
3 简单跳过。
4 简单跳过。
5 可以将这两个函数都声明为静态,或者在名称空间中定义它们。
6(需要解释的可以留言)
1040
Other:10,1another():10,-4
7
14, 1, 22//后面的优先4,1,22
P a r t 2 Part2 Part2.编程题
1
//golf.cpp#include<cstring>#include<iostream>#include"golf.h"using std::strcpy;using std::cin;using std::cout;using std::endl;voidsetgolf(golf & g,constchar* name,int hc){
cout<<"using void setgolf"strcpy(g.fullname,name);
g.handicap = hc;}intsetgolf(golf & g){
char name[Len];
cout<<"please enter the name of this golf:\n";
cin>>name;int hc;
cout<<"please enter the handicap of this gole:\n";
cin>>hc;setgolf(g,name,hc);}voidhandicap(golf & g,int hc){
g.handicap = hc;}voidshowgolf
这里写目录标题part1part1part1.复习题Part2Part2Part2.编程题part1part1part1.复习题1a. 形参使用自动变量,就是是auto int home;,auto可以省略b. 在一个文件中定义为外部变量(全局变量),在另一个文件中使用extern关键字来声明它。c. 在外部定义前加上关键字static,使它为文件链接性为内部的静态变量,也可以在未命名的命名空间中定义。d. 在该函数中声明为static int beencalled;,使它为本地静态变量。