|
一看就知道是找人做作业的~
理解你的心情~
//////////////////////////////////////////////////////
头文件
#include <iostream>
using namespace std;
class date
{
public:
date(int ys=0,int ms=0,int ds=0)
{year=ys;
month=ms;
day=ds;
}
date(date & d)
{year=d.year;
month=d.month;
day=d.day;
}
int gety(){return year;}
int getm(){return month;}
int getd(){return day;}
~date(){}
private:
int year;
int month;
int day;
};
class people
{private:
int number;
char sex;
unsigned id;
date birthday;
public:
people(int y,int m,int d);
people(people & p);
void setno(int no){number=no;}
void setsex(char se){sex=se;}
void setid(unsigned ids){id=ids;}
int getno(){return number;}
char getsex(){return sex;}
unsigned getid(){return id;}
void display(){cout<<number<<sex<<id<<birthday.gety()<<birthday.getm()<<birthday.getd()<<endl;}
};
people::people(int y,int m,int d):birthday(y,m,d)
{number=0;
sex='m';
id=0;
}
people::people(people &p):birthday(p.birthday)
{
number=p.number;
sex=p.sex;
id=p.id;
}
////////////////////////////////////////////
主函数
#include<iostream>
#include "lei.h"
using namespace std;
void main()
{int no,ys,ms,ds;
char se;
unsigned id;
cout<<"输入第一个人的编号,性别,身份证号,出生日期:"<<endl;
cin>>no>>se>>id>>ys>>ms>>ds;
//date da1(ys,ms,ds);
people p1(ys,ms,ds) ;
p1.setno(no);
p1.setsex(se);
p1.setid( id);
cout<<"第一个人的信息:";
p1.display();
}
基本上你在稍加修改就可以了。
希望你能真正学会 |
|