/////////////////////////////////////////////////////////////// // MT2-Q5 - behave like a std::string with added method // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2018 // /////////////////////////////////////////////////////////////// #include #include class stringEx : public std::string { public: stringEx(const char* sPtr) : std::string(sPtr) {} stringEx(const std::string& str) : std::string(str) {} // compiler defined copy ctor, copy assignment, and destruction // are correct so we don't supply them void title() { std::cout << "\n " << *this; std::cout << "\n " << std::string(this->size() + 2, '-'); } }; int main() { stringEx tl = "MT2-Q5 - behave like string with added method"; tl.title(); stringEx se = std::string("Hello CSE687"); se.title(); se = "Hello again"; se.title(); std::cout << "\n\n"; }