阅读程序分析结果第6章Word格式.docx

上传人:b****1 文档编号:6046952 上传时间:2023-05-05 格式:DOCX 页数:37 大小:19.39KB
下载 相关 举报
阅读程序分析结果第6章Word格式.docx_第1页
第1页 / 共37页
阅读程序分析结果第6章Word格式.docx_第2页
第2页 / 共37页
阅读程序分析结果第6章Word格式.docx_第3页
第3页 / 共37页
阅读程序分析结果第6章Word格式.docx_第4页
第4页 / 共37页
阅读程序分析结果第6章Word格式.docx_第5页
第5页 / 共37页
阅读程序分析结果第6章Word格式.docx_第6页
第6页 / 共37页
阅读程序分析结果第6章Word格式.docx_第7页
第7页 / 共37页
阅读程序分析结果第6章Word格式.docx_第8页
第8页 / 共37页
阅读程序分析结果第6章Word格式.docx_第9页
第9页 / 共37页
阅读程序分析结果第6章Word格式.docx_第10页
第10页 / 共37页
阅读程序分析结果第6章Word格式.docx_第11页
第11页 / 共37页
阅读程序分析结果第6章Word格式.docx_第12页
第12页 / 共37页
阅读程序分析结果第6章Word格式.docx_第13页
第13页 / 共37页
阅读程序分析结果第6章Word格式.docx_第14页
第14页 / 共37页
阅读程序分析结果第6章Word格式.docx_第15页
第15页 / 共37页
阅读程序分析结果第6章Word格式.docx_第16页
第16页 / 共37页
阅读程序分析结果第6章Word格式.docx_第17页
第17页 / 共37页
阅读程序分析结果第6章Word格式.docx_第18页
第18页 / 共37页
阅读程序分析结果第6章Word格式.docx_第19页
第19页 / 共37页
阅读程序分析结果第6章Word格式.docx_第20页
第20页 / 共37页
亲,该文档总共37页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

阅读程序分析结果第6章Word格式.docx

《阅读程序分析结果第6章Word格式.docx》由会员分享,可在线阅读,更多相关《阅读程序分析结果第6章Word格式.docx(37页珍藏版)》请在冰点文库上搜索。

阅读程序分析结果第6章Word格式.docx

pfun=A:

setm;

(a.*pfun)(10);

setn;

(a.*pfun)(20);

程序4

public:

intfun(intb){returna*c+b;

A(inti){a=i;

intc;

private:

inta;

Ax(8);

*pc;

pc=&

x.*pc=3;

int(A:

fun;

A*p=&

x;

(p->

*pfun)(5)<

程序5

intx,y;

voidfun(inti,int*j)

i=i+1;

*j=*j+1;

voidprint(){cout<

x<

y;

x=1,y=2;

fun(x,&

y);

print();

程序6

#include<

classM

M(){x=y=0;

M(inti,intj){x=i;

y=j;

}

voidcopy(M*m)

{x=m->

y=m->

voidsetxy(inti,intj){x=i;

voidprint(){cout<

"

y<

intx,y;

voidfun(Mm1,M*m2)

m1.setxy(12,15);

m2->

setxy(22,25);

{

Mp(5,7),q;

q.copy(&

p);

fun(p,&

q);

p.print();

q.print();

程序7

voidfun(inti,int&

j)

i=i+1;

j=j+1;

voidprint()

fun(x,y);

程序8

voidcopy(M&

m)

x=m.x;

y=m.y;

voidsetxy(inti,intj)

x=i;

y=j;

voidprint()

{

intx,y;

voidfun(Mm1,M&

m2)

m1.setxy(12,15);

m2.setxy(22,25);

q.copy(p);

fun(p,q);

程序9

classP

P(intm,intn){x=m;

y=n;

P(){x=1;

y=1;

P(inta,int*b){x=a;

y=*b;

voidsetxy(inti,intj){x=i;

voidprintxy(){cout<

P(P&

q){x=q.x+1;

y=q.y+1;

voidfun(Px,P&

y)

x.printxy();

y.printxy();

x.setxy(3,4);

y.setxy(6,7);

intxx=5,yy=7;

Pc(1,2),d,e(xx,&

yy);

fun(c,d);

c.printxy();

d.printxy();

e.printxy();

程序10

A(){a=b=0;

A(inti,intj){a=i;

b=j;

voidcopy(A&

aa);

voidprint(){cout<

a<

b<

inta,b;

voidA:

copy(A&

aa)

if(this==&

aa)return;

*this=aa;

voidmain()

Aa1,a2(3,4);

a1.copy(a2);

a1.print();

程序11

A(inti){a=i;

voidprint()

this->

Ax(8),y(50);

x.print();

y.print();

程序12

intcompare(An)

if(this->

a==n.a)

return1;

else

return0;

Ax(5),y(10),z(5);

pare(y)<

pare(x)<

classLocal

voidini(intx,inty)

{X=x;

Y=y;

Localadd(Localb)

Localc;

c.X=this->

X+b.X;

c.Y=this->

Y+b.Y;

returnc;

{cout<

X<

+"

Y<

i"

intX,Y;

}a,b;

a.ini(5,6);

b.ini(5,10);

a.add(b).print();

程序14

intX;

voidini(intX)

{this->

X=X*X;

}a;

a.ini(5);

a.print();

程序15

classMyClass

intn;

MyClass(){}

MyClass(intm){n=m;

voidaddvalue(intm)

MyClasss1;

s1.n=n+m;

*this=s1;

MyClasss(10);

s.disp();

s.addvalue(5);

程序16

classexam

intx;

voidsetx(intn)

x=n;

}

intgetx()

returnx;

};

examob[4];

inti;

for(i=0;

i<

4;

i++)

ob[i].setx(i);

ob[i].getx()<

"

程序17

intx;

exam(intn){x=n;

}intgetx(){returnx;

voidmain()

examob[4]={1,2,3,4};

endl;

程序18

classexam

exam(){x=3;

}//不带参数的构造函数

}//带参数的构造函数

intgetx(){returnx;

}

intmain()

examop

(2);

//调用带参数的构造函数

opx="

op.getx()<

//调用不带参数的构造函数

ob[2]x="

ob[2].getx()<

return0;

程序19

classDATE{

DATE()

{

month=year=day=0;

cout<

defaultconstructorcalled\n"

;

}

DATE(intm,intd,inty)

month=m;

day=d;

year=y;

constructorcalled\n"

~DATE()

destructorcalled\n"

voidPrint()

{

cout<

month="

month<

day="

day<

year="

year<

intmonth,day,year;

DATEa[5]={DATE(7,22,1998),DATE(7,23,1998),DATE(7,24,1998)};

a[3]=DATE(7,25,1998);

a[4]=DATE(7,26,1998);

for(inti=0;

5;

a[i].Print();

程序20

inta[][3]={1,2,3,4,5,6,7,8,9};

int(*pa)[3](a);

I<

3;

I++)

\n"

for(intj=0;

j<

j++)

*(*(pa+i)+j)<

程序21

M(){a=b=0;

M(inti,intj){a=i;

b=j;

voidprint(){cout<

'

\t'

inta,b;

Mm[2][4];

intx=10,y=10;

for(inti=0;

2;

for(intj=0;

m[i][j]=M(x+=2,y+=10);

M(*pm)[4](m);

for(i=0;

(*(*(pm+i)+j)).print();

程序22

char*name[5]={"

Tom"

"

John"

Mary"

SmithBlack"

Rose"

name[i]<

程序23

classA{

A(intI=0,intj=0){a=I;

voidprint(){cout<

“,”<

{Aa1(7,8),a2,a3(5,7);

A*b[3]={&

a3,&

a2,&

a1};

for(intI=0;

I++)b[I]->

print();

程序24

P(chari){a=i;

a;

chara;

•voidmain()

•{

•Ps('

a'

);

•P*x=&

s;

•x->

print();

•}

或者采用下面的主函数

Ps[3]={'

'

b'

c'

P*x=s;

x[i].print();

程序25

classSample

voidsetx(inti)

{x=i;

intputx()

{returnx;

Sample*p;

SampleA[3];

A[0].setx(5);

A[1].setx(6);

A[2].setx(7);

p=&

A[j];

p->

putx();

程序26

classEx

Ex(intx,charc='

~Ex()

voidoutdata()

ch<

da<

intda;

charch;

Ex:

Ex(intx,charc):

da(x),ch(c)

A'

Exw(3,'

),y

(1);

Exz[2]={Ex(10,'

),Ex(1,'

d'

)};

w.outdata();

y.outdata();

z[0].outdata();

程序27

•classSample

•intx;

•public:

•Sample(){}

•voidsetx(inti){x=i;

•friendintmax(SampleB[],intn)

•{intm=0;

•for(inti=0;

•if(B[i].x>

m)m=B[i].x;

•returnm;

•}

•};

•SampleA[10];

•intArr[]={90,87,42,78,97,84,60,55,78,65};

10;

A[i].setx(Arr[i]);

max(A,10)<

程序28

iostream.h>

constintN=6;

//符号常量

voidprint(constint*p,intn);

//常指针作函数参数

intarray[N];

N;

cin>

>

array[i];

print(array,N);

//数组名为实参

voidprint(constint*p,intn)

{"

*p;

for(inti=1;

*(p+i);

}"

程序29

classK

K(inti){k=i;

intsetk()const

{returnk;

intk;

intadd(constK&

g1,constK&

g2)

intsum=g1.setk()+g2.setk();

returnsum;

Kk1(8),k2(17);

ints=add(k1,k2);

s<

程序30

M(intx,inty){X=x;

voidMove(intx,inty)

voidPrint()const

{cout<

constMm1(1,2);

m1.Move(3,3);

//错误

m1.Print();

Mm2(3,4);

m2.Move(3,3);

m2.Print();

程序31

classR{

intR1,R2;

R(intr1,intr2){R1=r1;

R2=r2;

voidprint();

voidprint()const;

//函数重载

voidR:

print()

R1<

R2<

endl;

print()const//常成员函数的实现

Ra(5,4);

a.print();

constRb(20,52);

b.print();

程序32

A(inti);

voidPrint();

constinta;

staticconstintb;

constint&

r;

constintA:

b=10;

A(inti):

a(i),r(a)

Print()

r<

Aa1(100),a2(0);

a1.Print();

a2.Print();

程序33

A(inti,intj)

{A1=i;

A2=j;

A1<

A2<

intA1,A2;

classB

B(inti,intj,intk):

a(i,j),b(k)

{}

//子对象成员函数的调用

//子对象

intb;

{Bb(6,7,8);

b.print();

程序34

A构造"

A1=i;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 小学教育 > 其它课程

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2