12.继承和派生.pptVIP

  • 6
  • 0
  • 约1.76万字
  • 约 67页
  • 2016-12-05 发布于湖北
  • 举报
class CTeacher :virtual public CPerson { public: CTeacher(char *name, int age, char sex = M) :CPerson(name, age, sex) // 调用基类构造函数进行初始化 {} void SetData( char *title, char *part, int years ) { strncpy(this-title, title, 20); strncpy(this-part, part, 20); this-workyears = years; } void ShowInfo() { cout职称:titleendl; cout部门:partendl; cout工龄:workyearsendl; } private: char title[20]; // 职称 char part[20]; // 部门 int workyears; // 工龄 }; class CAssistant : public CTeacher, public CStudent { public: CAssistant(char *tname, int tage, char tsex, char *nam

文档评论(0)

1亿VIP精品文档

相关文档