#include<iostream>
#include<string>
using namespace std;
class date
{
public:
/*
date()//构造
{
yy=2000;
mm=5;
dd=4;
cout<<"date constructor..."<<endl;
}
*/
date(int y=2000,int m=5,int d=4)//构造
{
yy=y;
mm=m;
dd=d;
cout<<"date constructor two..."<<endl;
}
date(date &rd)//拷贝构造
{
yy=rd.yy;
mm=rd.mm;
dd=rd.dd;
cout<<"date copy constructor..."<<endl;
}
~date()
{
cout<<"date destructor..."<<endl;
}
void show()
{
cout<<"brithday:year/month/day"<<yy<<"/"<<mm<<"/"<<dd<<endl;
}
private:
int yy;
int mm;
int dd;
};
class student
{
public:
/*
student()
{
m_num=201720180101;
m_name="zhang";
cout<<"student constructor..."<<endl;
}
*/
student(string n,string s,int y,int m,int d):m_bri(y,m,d)
{
m_num=n;
m_name=s;
cout<<"student constructor two..."<<endl;
}
student(string n,string s,date &rd):m_bri(rd)
{
m_num=n;
m_name=s;
cout<<"student constructor three..."<<endl;
}
student(student &rs)//拷贝构造
{
m_num=rs.m_num;
m_name=rs.m_name;
cout<<"student copy constructor..."<<endl;
}
~student()//析构
{
cout<<"student destructor..."<<endl;
}
void printinfo()
{
cout<<"number:"<<m_num<<" name:"<<m_name<<" ";
m_bri.show();
}
private:
string m_num;
string m_name;
date m_bri;
};
int main()
{
student s1("201720180101","zhou",1996,1,1);
s1.printinfo();
date tday(2018,4,16);
student s2("201720181601","wang",tday);
s2.printinfo();
//student s3();
//s3.printinfo();
return 0;
}
学生类
网友评论
```
class Hello {
main() {
}
}
```