// arrayair.cpp // creates array of airtime objects #include #include // for setw(), etc. #include // for getche() class airtime { private: int minutes; // 0 to 59 int hours; // 0 to 23 public: void set() { char dummy; // for colon cout << "Enter time (format 23:59): "; cin >> hours >> dummy >> minutes; } void display() { cout << hours << ':' << setfill('0') << setw(2) << minutes; } }; void main() { airtime at[20]; // array of 20 airtime objects int n = 0; // number of airtimes in array char choice; do { // get time from user cout << "Airtime " << n << ". "; // and insert in array at[n++].set(); cout << "Do another (y/n)? "; cin >> choice; } while(choice != 'n'); // display every airtime in the array for(int j = 0; j < n; ++j) { cout << "\nAirtime " << j << " = "; at[j].display(); } // stop the flow on the monitor getch(); } //end main