资源简介
设计一个用于人事管理的“人员”类。由于考虑到通用性,这里只抽象出所有类型人员都具有的属性:编号、性别、出生日期、身份证号等。其中“出生日期一个“日期”类内嵌子对象。用成员函数实现对人员信息的录入和显示。要求包括:构造函数和析构函数、拷贝构造函数、内联成员函数、带默认形参值的成员函数、组合。

代码片段和文件信息
#include
#include
using namespace std;
class Date //日期类
{
private:
int yearmonthday;
public:
void SetDate(int Y=0int M=0int D=0); //带默认形参值的成员函数
void ShowDate();
};
inline void Date::SetDate(int Yint Mint D) //录入日期(内联成员函数)
{
cin>>Y>>M>>D;
year=Y;
month=M;
day=D;
}
inline void Date::ShowDate() //显示日期(内联成员函数)
{
cout< }
class Personnel //人员类
{
private:
int num;
char sex;
Date birthday; //“日期”类内嵌子对象,类的组合
string ID;
public:
Personnel(){} //默认构造函数
Personnel(int nchar sDate bstring id) //带参构造函数
{
num=n;
sex=s;
birthday=b;
ID=id;
}
Personnel (Personnel &p); //声明拷贝构造函数
~Personnel() //析构函数
{
cout< }
void SetPersonnel();
void ShowPersonnel();
};
Personnel::Personnel (Personnel &p) //定义拷贝构造函数
{
num=p.num;
sex=p.sex;
birthday=p.birthday;
ID=p.ID;
}
void Personnel::SetPersonnel() //录入人员信息
{
cout<<“录入人员信息:“< cout<<“请输入人员编号:“< cin>>num;
cout<<“请输入人员性别(m或f):“< cin>>sex;
cout<<“请输入人员出生日期:“< birthday.SetDate();
cout<<“请输入人员身份证号:“< cin>>ID;
}
void Personnel::ShowPersonnel() //显示人员信息
{
cout<<“人员编号:“< cout<<“人员性别“< cout<<“人员出生日期:“;
birthday.ShowDate();
cout<<“人员身份证号:“< }
int main() //主函数
{
int flag=1;
while(flag) //循环录入
{
Personnel per;
per.SetPersonnel();
per.ShowPersonnel();
cout<<“继续输入“y”,结束输入“n”:“< char c;
cin>>c;
if(c==‘N‘||c==‘n‘) flag=0;
}
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 548907 2009-11-13 15:33 4-10.exe
文件 1815 2009-11-13 15:33 4-10.cpp
文件 308 2009-11-13 15:36 4-10.txt
----------- --------- ---------- ----- ----
551030 3
相关资源
- VisualStudioUninstaller vs卸载工具
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- 使用选择性重传协议实现UDP可靠通信
- VC 获得文件属性 获取文件的创建时
- 读者写者问题(读者优先,写者优先
- 用VC 编写的仿QQ聊天室程序源代码
- 外点法程序
- 外罚函数程序
- qt-电子点菜系统
- 推箱子及人工智能寻路C 源代码
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- MUSIC算法c 实现
- C 餐厅叫号系统(QT平)
- 国际象棋c 完整版
-
ob
jectARX给Auto CAD加工具条 - 画图程序MFC/VC/VC CRectTracker 串行化
- MFC网络编程实例
- c 课程设计 职工信息管理系统
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- 清华大学 c 郑莉 ppt课件
- c 程序判断离散数学中命题公式
- 多项式求和(数据结构C 版)
- vc 6.0开发的流程图编辑器
- VC 天空盒(skyBox)实现(附源代码)
- c MFC 画多边形
- 用C 实现的对网络上的ARP数据包进行
- Microsoft基本类库 (MFC)(C 库)
评论
共有 条评论