#ifndef MT2Q4_H #define MT2Q4_H /////////////////////////////////////////////////////////////// // MT2Q4.h - Logger // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2012 // /////////////////////////////////////////////////////////////// #include #include class logger : public std::string { public: logger(const std::string& title) { char* pTemp = new char[title.size() + 1]; for(size_t i=0; i<= title.size(); ++i) pTemp[i] = title[i]; pTitle = pTemp; } logger(const logger& l) : std::string(l) // copy base part { int len = strlen(l.pTitle); char* pTemp = new char[len + 1]; for(int i=0; i<= len; ++i) pTemp[i] = l.pTitle[i]; pTitle = pTemp; } ~logger() { delete[] pTitle; } std::string title() { return std::string(pTitle); } private: logger& operator=(const logger&); // didn't implement - not part of question const char* pTitle; // can change address but not contents of address }; #endif