#include<iostream>
using namespace std;
class D{
private:
int year;
int month;
int day;
public :
D(int y,int m,int d)
{
cout<<"Constructing D"<<endl;
year=y;
month=m;
day=d;
}
~D()
{
cout<<"释放D......\n";
}
void Show()
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
};
class Time
{
private:
int hour;
int minute;
int second;
public:
Time(int h, int m, int s)
{
cout<<"Constructing Time"<<endl;
hour=h;
minute=m;
second=s;
}
~Time()
{
cout<<"释放Time\n";
}
void Show()
{
cout<<hour<<":"<<minute<<":"<<second<<endl;
}
};
class Schedule
{
private:
int number;
D date; // 定义对象成员 date
Time time; // 定义对象成员 time
public:
Schedule(int num, int a, int b, int c, int d, int e, int f): date(a,b,c), time(d,e,f)
{
cout<<"Constructing Schedule"<<endl;
number=num;
}
~Schedule()
{
cout<<"释放Schedule"<<endl;
}
void show()
{
cout<<"number"<<number<<":";
date.Show(); // 调用对象成员date的show()函数
time.Show(); // 调用对象成员time的 show()函数
}
};
int main()
{
Schedule obj1(1,2008,3,12,12,10,0);
obj1.show();
Schedule obj2(2,2009,2,8,18,20,0);
obj2.show();
return 0;
}
using namespace std;
class D{
private:
int year;
int month;
int day;
public :
D(int y,int m,int d)
{
cout<<"Constructing D"<<endl;
year=y;
month=m;
day=d;
}
~D()
{
cout<<"释放D......\n";
}
void Show()
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
};
class Time
{
private:
int hour;
int minute;
int second;
public:
Time(int h, int m, int s)
{
cout<<"Constructing Time"<<endl;
hour=h;
minute=m;
second=s;
}
~Time()
{
cout<<"释放Time\n";
}
void Show()
{
cout<<hour<<":"<<minute<<":"<<second<<endl;
}
};
class Schedule
{
private:
int number;
D date; // 定义对象成员 date
Time time; // 定义对象成员 time
public:
Schedule(int num, int a, int b, int c, int d, int e, int f): date(a,b,c), time(d,e,f)
{
cout<<"Constructing Schedule"<<endl;
number=num;
}
~Schedule()
{
cout<<"释放Schedule"<<endl;
}
void show()
{
cout<<"number"<<number<<":";
date.Show(); // 调用对象成员date的show()函数
time.Show(); // 调用对象成员time的 show()函数
}
};
int main()
{
Schedule obj1(1,2008,3,12,12,10,0);
obj1.show();
Schedule obj2(2,2009,2,8,18,20,0);
obj2.show();
return 0;
}