#include #include using namespace std; class Text { public: Text(): text{} {} Text(string const& t): text{t} {} operator string() const { return text; } Text operator+(Text const& other) const { Text tmp{text + other.text}; return tmp; } Text operator-(char c) const { string tmp{text}; string::size_type n{tmp.find(c)}; if ( n != string::npos ) { tmp.erase(n, 1); } return Text{tmp}; } Text operator*(int times) const { Text tmp{}; for ( int i{0}; i < times; ++i ) { tmp = tmp + *this; } return tmp; } private: string text; }; ostream& operator<<(ostream& lhs, Text const& rhs) { return lhs << string(rhs); } int main() { Text const t1{"Hej"}; Text const t2{"Svej"}; Text t3{t1+t2}; cout << t1 << " + " << t2 << " = " << t3 << '\n'; cout << t3 << " * " << 4 << " = " << t3 * 4 << '\n'; cout << t3 << " - " << "'e'" << " = " << t3 - 'e' << endl; }