www.gusucode.com > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序 > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序/code/C++例题程序/第4章/s4_9/sclass4_9_student.cpp
//Download by http://www.NewXing.com //类的实现文件 //文件名:ch4_9\sclass4_9_student.cpp #include "sclass4_9_student.h" //包含类定义头文件 //CPerson构造函数 CPerson::CPerson() { m_lpszName = NULL; m_lpszSex = NULL; } //CPerson构造函数 CPerson::~CPerson() { } //SetAttribute()的实现 void CPerson::SetAttribute() { m_lpszName = "无名氏"; m_lpszSex = "无性"; cout << "姓名:" << m_lpszName << ";性别:" << m_lpszSex << "。" << endl; } //SetAttribute(char * )设置学生姓名 void CPerson::SetAttribute(char *lpszName) { m_lpszName = lpszName; cout << "姓名:" << m_lpszName << ";性别:" << m_lpszSex << "。" << endl; } //SetAttribute(char *, char *)设置学生姓名和性别 void CPerson::SetAttribute(char *lpszName, char *lpszSex) { m_lpszName = lpszName; m_lpszSex = lpszSex; cout << "姓名:" << m_lpszName << ";性别:" << m_lpszSex << "。" << endl; }