~急 在线等 5000分~!很简单~!!!求教~!

xunkan 2004-04-07 07:41:47
主  题: 设计一个用于人事管理的模块~急 在线等
作  者: xunkan (软体动物)
等  级:
信 誉 分: 100
人  气: 0
所属论坛: C/C++ C++ / 面向对象
问题点数: 100
回复次数: 0
发表时间: 2004-4-7 19:37:42



我们在上机实习 求教~ 晚上要交

属性:
number
sex
birthday

其中birthday
为日期类的内嵌子对象

用成员函数实现对人员信息的录入和显示

要求用到构造函数
析构函数 拷贝构造函数
内联成员函数
组合

我马上要提交
#include<iostream>
using namespace std;
class tree
{
public:
tree(int n=0);
void grow(int years);
void age();
private:
int ages;
};
tree::tree(int n)
{
ages=n;
}
void tree::age()
{
cout<<"the age of the tree is "<<ages<<endl;
}
void tree::grow(int years)
{
ages+=years;
}
void main()
{
tree TREE(500);
TREE.age();
TREE.grow(300);
TREE.age();
}




分不够可以继续加 最多5000 给出完整代码~~!!! 多谢~~~
...全文
64 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Seekhunter 2004-04-08
  • 打赏
  • 举报
回复
#include<iostream.h>
#include <string.h>
#define MALE 0
#define FEMALE 1
class PeopleResource
{
public:
PeopleResource()
{
sex=MALE;
}
PeopleResource(int inputNumber,char inputSex[],int inputAge,char inputID[])
{
number=inputNumber;
sex=(sizeof(inputSex)==6)?FEMALE:MALE;
age=inputAge;
strcpy(ID,inputID);
}
void setSex(char inputSex[])
{
switch (sizeof(inputSex))
{
case 4:sex=MALE;
case 6:sex=FEMALE;
default :cerr<<"Wrong sex inputed!";

}
}
void setNumber(int inputNumber) {number=inputNumber;}
void setAge(int inputAge) {age=inputAge;}
void setID(char inputID[]) {strcpy(ID,inputID);}
void setBirthday(int inputYear,int inputMonth,int inputDay) {birthday.setDate(inputYear,inputMonth,inputDay);}

void getSex()
{
cout<<"No."<<number<<" is "<<((sex==0)?"MALE":"FEMALE")<<endl;
}
void getAge()
{
(age!=NULL && cout<<"The age of No."<<number<<" is "<<age<<endl)||cerr<<"The age of No."<<number<<"wasn't inputed."<<endl ;
}
void getID()
{
(ID!=NULL && cout<<"The ID of No."<<number<<" is "<<ID<<endl)||cerr<<"The ID of No."<<number<<"wasn't inputed."<<endl ;
}
void getBirthday()
{
cout<<"The birthday of No."<<number<<" is ";
birthday.getDate();
cout<<endl ;
}
private:

class DAY
{

public:
void setDate(int inputYear,int inputMonth,int inputDay)
{
year=inputYear;
month=inputMonth;
day=inputDay;
}

void getDate()
{
cout<<month<<"/"<<day<<"/"<<year;
}
private:
int year,month,day;
};
DAY birthday;
int number;
int sex;
int age;
char ID[30];
};
xunkan 2004-04-07
  • 打赏
  • 举报
回复
等待jzr出手相助~!!!
xunkan 2004-04-07
  • 打赏
  • 举报
回复
但是来不及了~
Wenxy1 2004-04-07
  • 打赏
  • 举报
回复
You should to see book.
xunkan 2004-04-07
  • 打赏
  • 举报
回复
在 qq 20027436
changyongshang 2004-04-07
  • 打赏
  • 举报
回复
你现在还在吗?
xunkan 2004-04-07
  • 打赏
  • 举报
回复
不用考虑输入的问题
zhangcrony 2004-04-07
  • 打赏
  • 举报
回复
Go to C/C++ Block, you may soon get the answer...

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧