www.gusucode.com > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序 > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序/code/C++例题程序/第4章/s4_2/sclass4_2_student.cpp
//Download by http://www.NewXing.com //类的实现文件 //文件名:ch4_2\sclass4_2_student.cpp #include "sclass4_2_student.h" //包含类定义头文件 //CPerson构造函数 CPerson::CPerson(char *lpszName, //姓名 char *lpszSex //性别 ) { m_lpszName = lpszName; m_lpszSex = lpszSex; } //显示人名和性别 void CPerson::Show( ) const { cout << m_lpszName << "|" << m_lpszSex << endl; } //CStudent构造函数 CStudent::CStudent(int iNumber, //学号 char *lpszName, //姓名 char *lpszSex //性别 ) : CPerson(lpszName, lpszSex) { m_iNumber = iNumber; } //显示学生姓名、性别、学号 void CStudent::Show( ) const { cout << m_lpszName << "|" << m_lpszSex << "|" << m_iNumber << endl; }