/* Problem 37 */ #include using namespace std; #include class test { char s[21]; public: test() { strcpy(s, "ate"); show(cout); } test(char c) { s[0] = c; s[1] = '\0'; show(cout); } test(char str[] ) { strcpy(s, str); show(cout); } ~test() { cout << '~'; show(cout); } void show(ostream &os) const { os << s << '\n'; } test &operator*(test x) { int i = 0; while (s[i] != '\0') i++; s[i] = '*'; i++; int j = 0; while ((i < 20) && (x.s[j] != '\0')) { s[i] = x.s[j]; i++; j++; } s[i] = '\0'; return *this; } }; ostream &operator<<(ostream &os, test x) { x.show(os); return os; } int main() { test a('i'), b, c("ter"); (a * c) * b; cout << a << b << c << "the end\n"; return 0; }