把一根木料锯成3段要3.6分钟,锯成8段要( )分钟。
12. 6
使用VC++6.0打开考生文件夹下的源程序文件3.cpp。类People包括姓名和年龄两个字段。函数fun获得年龄比较大的人的姓名,然后输出这个姓名到屏幕。 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)完成类的构造函数功能,请在注释1后添加适当的语句。 (2)完成构造函数对姓名的赋值,请在注释2后添加适当的语句。 (3)定义类的友元函数fun,请在注释3后添加适当的语句。 (4)补充函数fun的年龄比较功能,请在注释4后添加适当的语句。 注意:增加或者修改代码的位置已经用符号表示出来,请不要修改其他的程序代码。 试题程序: #include<iostream.h> class People public: //********1******** int i; for(i=0;sUserName[i]!=0;i++) m_UserName[i]=sUserName[i]; //********2******** m_Old=nOld; private: char m_UserName[32]; int m_Old; //********3******** ; void fun(char *s,People& person1,People&person2) //********4******** if() for(int i=0;person1.m_UserNamd[i]!=0;i++) s[i]=person1.m_UserName[i]; s[i+1]=0; else for(int i=0;person2.m_UserName[i]!=0;i++) s[i]=person2.m_UserName[i]; s[i+1]=0; void main() char s[32]; People p1("abc",20); People p2("def",30); fun(s,p1,p2); cout<<s<<end1; return;
全隔片