// THIS CODE IS NOT SELF-CONTAINED IN THE TEXTBOOK -header lines needed


#include<iostream>

using namespace std;

class Date {

   int day;
   int month;
   int year;

public:

   Date(int d = 1, int m = 1, int y = 2006)
      : day(d), month(m), year(y) // non-class types,
                                  // i.e. intitializer list
                                  // alternative to assignment
                                  // in the body
   {
//    day = d; month = m; year = y;
      cout << "A Date was just created with value: "
           << day << ' ' << month << ' ' << year << endl; }

   ~Date()
   {  cout << '\n' << "A Date is to be destroyed with value: "
           << day << ' ' << month << ' ' << year << endl; }

   void print() const
   {  cout << day << ' ' << month << ' ' << year << endl; }
};

class Time {

   int hours;
   int mins;

public:

   Time(int h = 0, int m = 0) : hours(h), mins(m)
   {  cout << "A Time was just created with value: "
           << hours << ' ' << mins << endl; }

   ~Time()
   {  cout << '\n' << "A Time is to be destroyed with value: "
           << hours << ' ' << mins << endl; }

   void print() const
   {  cout << hours <<" hours  and "<< mins <<" mins " << endl; }
};

class DetailedDate {

   Date date;
   Time time;

public:

   DetailedDate()
// The default constructors of the data members are used
   {  cout << "DetailedDate was just created with value:"
           << endl;

// NO VISIBILITY in private part
//    cout << date.day << ' ' << date.month << ' '
//         << date.year << endl;
//    cout << time.hours << " hours and "
//         << time.mins << " mins " << endl;

      date.print();
      time.print();
   }

// DetailedDate(int d, int mo, int y, int h, int mi) :
   DetailedDate(int d, int mo = 0, int y = 0, int h = 0, int mi = 0) :
      date(d,mo,y), time(h,mi)
// Initializer list is required to pass the values
// to the constructors of data members.
   {  cout << "DetailedDate was just created with value:"
           << '\n' << endl;

      date.print();
      time.print();
   }

   ~DetailedDate()
   {  cout << '\n'
           << "A DetailedDate is to be destroyed with value: " << endl;
      date.print();
      time.print();
   }

   void print() const
   {  cout << "I am printing a DetailedDate " << endl;
      date.print();
      time.print();
   }
};

int main()
{
// Date d1;
// Date d2(3);
// Date d3(3,4);
// Date d4(3,4,2005);

// Time t1;
// Time t2(5);
// Time t3(2,35);

// dd1, dd2 and dd3 are instances/objects of DetailedDate

   DetailedDate dd1;
// DetailedDate dd2(10);
// DetailedDate dd3(10,1);
// DetailedDate dd4(10,1,2007);
// DetailedDate dd5(10,1,2007,11);
// DetailedDate dd6(25,10,2005,3,45);

   dd1.print();

   return 0;
}
