您好,欢迎访问三七文档
//声明一个Employee类,其中包括姓名、街道地址、城市和邮编等属性,以及chang_name()//和display()等函数。display()显示姓名、街道地址、城市和邮编等属性,chang_name()改变//对象的姓名属性,实现并测试这个类。#includeiostream.hinti,j,k;//charname1[],add1[],city1[],postCode1[];classEmployee{public:Employee(charname1[],charadd1[],charcity1[],charpostCode1[]);voidset();voidchange_name();voiddisplay();voidjixu();private:char*name,*add,*city,*postCode,*name1;};Employee::Employee(charname1[],charadd1[],charcity1[],charpostCode1[]){name=name1;add=add1;city=city1;postCode=postCode1;}voidEmployee::change_name(){cinname1;name=name1;}voidEmployee::set(){charname1[10],add1[10],city1[10],postCode1[10];name=name1;add=add1;city=city1;postCode=postCode1;}voidEmployee::display(){cout姓名:nameendl;cout街道地址:addendl;cout城市:cityendl;cout邮政编码:postCodeendl;}voidEmployee::jixu(){coutendlendlendl;cout是否要修改姓名信息:endl1、是2、否endl;cini;if(i==1)k=1;if(i==2)k=0;}voidmain(){Employeeabc(小明,建设一路,武汉,100056);cout修改前属性信息:endl;abc.display();j=1;while(j){j=0;abc.jixu();j=k;if(j==1){cout请输入姓名信息:endl;//cinname1;abc.change_name();abc.set();abc.display();}}}
本文标题:声明一个Employee类,其中包括姓名、街道地址、城市和邮编等属性,以及chang_name()和
链接地址:https://www.777doc.com/doc-6371345 .html