C++例题.docxVIP

  • 39
  • 0
  • 约1.06万字
  • 约 18页
  • 2017-02-09 发布于重庆
  • 举报
C例题

例1:创建一个employee类,该类中有字符数组,表示姓名、街道地址、市、省和邮政编码。把构造函数、changname()、display()的函数的原型放在类定义中,构造函数初始化每个成员,display()函数把完整的对象数据打印出来。其中的数据成员是保护的,函数是公共的。#includeiostream.h #includestring.h class employee { protected: char name[10]; // 姓名char street[20]; // 街道地址char city[10]; // 市char prov[10]; // 省char post[7]; // 邮政编码int no; // 记录序号public: employee(char [],char [],char [],char [],char [],int); void changename(char str[]); void display(); }; employee::employee(char n[],char s[],char c[], char p1[],char p2[

文档评论(0)

1亿VIP精品文档

相关文档