#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 << "I just created a Date with value: "
                   << day << ' ' << month << ' ' << year << endl;

             }


        ~Date() { 

                   cout << '\n' << "I am destroying a Date with value: "
                   << day << ' ' << month << ' ' << year << endl;
                 }
        void print() { 
                   cout << day << ' ' << month << ' ' << year << endl;}

    };



/////////////////////////////////////////////////////////////////////

class Time {

      int hours;
      int mins;

 public:

      Time(int h = 0, int m = 0 ) 
        : hours(h), mins(m)
          { 

//             hours = h; mins = m; 
             cout << "I just created a Time with value: "
                  << hours << ' ' << mins << endl; 

          }

      ~Time() { 

                cout << '\n' << "I am destroying a Time with value: "
                     << hours << ' ' << mins << endl; }

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

};


/////////////////////////////////////////////////////////////////////

class DetailedDate{

       Date date;
       Time time;

      public:

        DetailedDate()

// Default constructor is synthesized, using the default constructors of
// the data members.
          { cout << "DetailedDate was just created with value:" << '\n' << 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' 
                    << "I am destroying a DetailedDate with value: " << 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(25,10,2005,3,45);

   return 0;
}

