全文预览

C 上机实验报告实验六

上传者:塑料瓶子 |  格式:docx  |  页数:13 |  大小:814KB

文档介绍
ple&p){?returnid==p.id;}People&People::operator=(People&p){?strcpy(name,p.name);?strcpy(number,p.number);?birthday=p.birthday;?strcpy(id,p.id);?return*this;}//检测==重载的普通函数voidtest(People&x,People&y){?if(strcmp(x.id,y.id)==0)?{ cout<<"Their'sIDsaresame"<<endl;?}?else?{ cout<<"Their'sIDsaredifferent"<<endl;?}}intmain(){?/*inti;?charspaceA;?//生成3个Date类型的对象?Datedate[3]={Date(0,0,0),Date(0,0,0),Date(0,0,0)};?//生成3个People类型的对象?Peopleperson[3]={People("0","0","0",date[0],"0"),People("0","0","0",date[1],"0"),People("0","0","0",date[2],"0")};?//设置这3个对象的各类信息?for(i=0;i<3;i++)?{?person[i].setName(); person[i].setNumber(); person[i].setSex(); person[i].setId(); date[i].setDate(); spaceA=getchar();?}?//输出这3个对象的各类信息?for(i=0;i<3;i++)?{ person[i].showPeople(); date[i].showDate();?}*/?//测试==重载?Dated1(0,0,0);

收藏

分享

举报
下载此文档