// // timetest.cpp: test time.h using pointers // // to build: g++ -std=c++11 timetest.cpp time.cpp // #include "time.h" #include using namespace std; void echo(Time *time, const char type[]) { cout << type << " time: "; time->print(cout); cout << endl; } int main() { Time *reg = new Time(7, 2); Time *mil = new MilTime(8, 9); if ( reg->hours() != 7 || mil->minutes() != 9 ) throw "Illegal time state."; if ( !reg->isMorning() ) throw "Broken am/pm check."; echo(reg, "Regular "); echo(mil, "Military"); return 0; } // OUTPUT: // Regular time: 07:02am // Military time: 0809