home *** CD-ROM | disk | FTP | other *** search
- // ex07023.cpp
- // Destructors for Arrays of classes
- #include <iostream.h>
-
- // ------- date class
- class Date {
- int mo, da, yr;
- public:
- Date() { mo = 0; da = 0; yr = 0; }
- Date(int m, int d, int y) { mo = m; da = d; yr = y;}
- ~Date();
- void display()
- { cout << '\n' << mo << '/' << da << '/' <<yr; }
- };
-
- // destructor that is called for each element in a Date array
- Date::~Date()
- {
- cout << "\nDate destructor running";
- }
-
- main()
- {
- Date dates[2];
- Date temp(6,24,40);
-
- dates[0] = temp;
- dates[0].display();
- dates[1].display();
- }