全国2006年10月高等教育自学考试面向对象程序设计试题(6)

2020-12-12 22:52

全国2006年10月高等教育自学考试

private:

float real, imag;

public:

Complex(float r=0, float i=0 ) { real=r; imag=i;}

void Display(){

cout << real;

if (imag>0) cout<<"+"<<imag<<"i" ;

else if (imag<0) cout<<imag<<"i" ;

cout << endl;

}

Complex operator+ (Complex &b );

friend Complex operator- ( Complex &a, Complex &b );

};

Complex Complex::operator+ (Complex &b)

{

Complex *t = new Complex ( ①________ );

return *t;

}

Complex operator- ( Complex &a, Complex &b )

{

Complex *t = new Complex ( ②________ );

return *t;

}

void main()

{

Complex c1(4.0,5.0),c2(2.0,-5.0),c3;

c3=c1+c2;

c3.Display();

c3=c1-c2;

c3.Display();

}

五、程序分析题(本大题共6小题,每小题5分,共30分)

31.写出下面程序的输出结果。

#include <iostream.h>

#include<iomanip.h>

int i=1;

void other(void)

{

static int a=2, b;

int c=10;

a=a+1; i=i+3; c=c+5;

cout<<setw(5)<<i<<setw(5)<<a<<setw(5)<<b<<setw(5)<<c<<endl;

b=a;

}

void main(void)

{

static int a;

int b=-5, c=0;

════════════════════════════════════════════════════════════════════

- 本套试题共分8页,当前页是第6页-


全国2006年10月高等教育自学考试面向对象程序设计试题(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:英国文学史_复习资料大二英语专业必考

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: