// Filename: NamedTimer.cxx // // Implementation #include #include #include "NamedTimer.h" using namespace std; // The constructor NamedTimer::NamedTimer(int minutes, int seconds, const char * name) :Timer(minutes, seconds) { theName = new char [strlen(name)+1]; strcpy(theName, name); } // The copy constructor NamedTimer::NamedTimer(const NamedTimer & existing) :Timer(existing) { theName = new char [strlen(existing.name())+1]; strcpy(theName, existing.name()); } // The assignment operator const NamedTimer & NamedTimer::operator =(const NamedTimer & rhs) { if (this != & rhs) { delete [] theName; theName = new char [strlen(rhs.name())+1]; strcpy(theName, rhs.name()); Timer::operator=(rhs); } return * this; } // prints name and the minutes and seconds remaining void NamedTimer::print(ostream & os) const { os << theName << " => "; Timer::print(os); // call superclass's print to do time } // returns the name of the timer const char * NamedTimer::name( ) const { return theName; }