1class Date {
2 unsigned int day;
3 unsigned int month;
4 unsigned int year;
5 public:
6 Date(void)
7 {
8 cout << "Default Date" << endl;
9 }
10
11 Date(int d, int m, int y)
12 {
13 if( d > 31 ){
14 cout << "invalid date" << endl;
15 getchar();
16 exit(0);
17 }
18 day = d;
19 month = m;
20 year = y;
21 cout << "Constructor Date" << endl;
22 }
23 ~Date()
24 {
25 cout << "Destructor Date" << endl;
26 }
27 void print(void)
28 {
29 cout << day << "/" << month << "/" << year << endl;
30 }
31
32 };
33
34class student{
35 char *name;
36 char *family;
37 char *stdNo;
38 unsigned int year;
39 Date birthday;
40
41 public:
42 student(char n[]="",char f[]="",char no[]="0",unsigned int y=1300,Date b=Date(1,1,1300))
43 {
44 name = new char[strlen(n)+1];
45 strcpy(name,n);
46 family = new char [strlen(f)+1];
47 strcpy(family,f);
48 stdNo = new char [strlen(no)+1];
49 strcpy(stdNo,no);
50 year = y;
51 birthday = b;
52 cout << "Constructor student" << endl;
53 }
54 ~student(void)
55 {
56 delete [] name;
57 delete [] family;
58 delete [] stdNo;
59 cout << "destructor student" << endl;
60 }
61 Date get_date(void)
62 {
63 return birthday;
64 }
65 void show()
66 {
67 cout << name << " " << family << endl;
68 cout << "Student Number: " << stdNo << endl;
69 cout << "Entrance year: " << year << endl;
70 cout << "Birthday: " ;
71 birthday.print();
72 }
73 };