全文预览

c.语言程序设计实验答案 数组、指针与字符串

上传者:相惜 |  格式:doc  |  页数:15 |  大小:293KB

文档介绍
trcpy(name,n);strcpy(street,s);?strcpy(city,c);?strcpy(mail,m);}voidEmployee::display(){?cout<<"姓名:"<<name<<endl;?cout<<"街道:"<<street<<endl;?cout<<"城市:"<<city<<endl;?cout<<"邮编:"<<mail<<endl;}voidEmployee::change_name(char*n){strcpy(name,n);}//lab6_5.cpp#include"lab6_5employee.h"voidmain(){?Employeeemp("张山","海甸三西路13号","海口市","570228");?emp.display();?emp.change_name("李世");?cout<<endl;?emp.display();}6.(编程,习题6-27)使用上一小题中的Employee类声明对象数组emp[5]。使用循环语句把数据显示出来。程序名:lab6_6.cpp。参考运行结果:★程序及运行结果://lab6_6.cpp#include"lab6_5employee.h"#include<iostream>usingnamespacestd;voidmain(){?Employeeemp[5]={Employee("n1","s1","c1","m1"), Employee("n2","s2","c2","m2"), Employee("n3","s3","c3","m3"), Employee("n4","s4","c4","m4"), Employee("n5","s5","c5","m5")};?for(inti=0;i<5;i++){ emp[i].display(); cout<<endl;?}}

收藏

分享

举报
下载此文档