// 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 "
           << endl;
    cout << "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();
//*/
/*
      cout << "----------------------------------------------" << endl;
      cout << "The size of Date is: " << sizeof(Date) << endl ;
      cout << "The size of Time is: " << sizeof(Time) << endl ;
      cout << "The size of DetailedDate is: " << sizeof(DetailedDate) << endl ;
      cout << "The size of DetailedDate data member date is: " << sizeof(date) << endl ;
      cout << "The size of DetailedDate data member time is: " << sizeof(time) << endl ;
      cout << "that is the size of an object of DetailedDate which is: " << sizeof(*this) << endl ;
      cout << "----------------------------------------------" << endl;
*/

    
   }

// 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()
{
   DetailedDate dd1;

   cout << '\n' << "---- PRINTING FROM main ----" << endl;

   dd1.print();

   cout << "---- END OF PRINTING FROM main ----" << endl;

   return 0;
}
