当前位置:首页 > 全国2011年10月自学考试C加加程序设计试题和答案
http://www.zikao5.com 我自考网整理
a. f1(1.6,3.8) ; p=&a; p. get( ) ; }
45. #include < iostream. h > class point{ int x;
public: void init ( int a) { x = a; }
int getx( ){ return x;} void setx ( int a) { x = a; } };
void main( ){ point a; a. init (20,30) ;
cout << a. getx( ) << endl; }
四、完成程序题(本大题共5小题,每小题4分,共20分) 46.完成下面类中成员函数的定义。
class test { private: int nl ; float fl; public:
test(int,float f); test(test&); };
test::test( ________ ) {nl=n; fl=f;} test:: test(test&t) {nl=t.nl; fl=________;}
47.在下面程序中的下划线处填上适当的语句,使程序的输出结果如下:
11,77 11,77
http://www.zikao5.com 我自考网整理
源程序如下: #include
void initxy(int a,int b){x=a;y=b;} void show() {________} } ; void main() {
base a,b; __________ a.show(); b=a; b.show(); }
48.在下面程序中的下划线处填上适当的程序,使程序的输出结果如下:
x=1,y=2 x=30,y=40 源程序如下: #include
Sample(){x=y=0;}
Sample(int i,int j){x=i;y=j;} void copy(Sample & s);
void setxy(int i,int j){x=i;y=j;}
void print(){cout<<\,y=\;} };
void Sample::copy (________)
http://www.zikao5.com 我自考网整理
{
x=s.x;y=s.y; }
void func(________) ) {
s1.setxy(10,20); s2.setxy(30,40); }
void main() {
Sample p(1,2),q; q.copy(p); func(p,q); p.print(); q.print(); } Sample&s }
49.在下面程序的下划线处填上正确的语句,使其得到下面的输出结果。
20 21 22 a[0]=20 a[1]=21 a[2]=22 程序清单如下: #include < iostream > using namespace std; class base {
private:int x; public:
void setx(int a){x=a;}
http://www.zikao5.com 我自考网整理
int getx(){return x;} } ; void main() {
base a [3],*p; a[0].setx(20); a[1].setx(21); a[2].setx(22); for(p=a; p 50.在下面程序中的下划线处填上适当的程序,使程序的输出结果如下: x=2,y=3 源程序如下: #include Sample(){x=y=0;} Sample(________){x=a;y=b;} void disp() { cout<<\,y=\; } } ; void main() { Sample s(2,3),________ P - >disp(); } 五、程序分析题(本大题共2小题,每小题5分,共10分) 51.请给出下面程序的输出结果 #include
共分享92篇相关文档