Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- class mystring :public std::string
- {
- public:
- mystring(): std::string()
- {}
- mystring(const char* str): std::string(str)
- {}
- mystring operator *(int n)
- {
- mystring ret;
- for (int i = 0; i < n; ++i) {
- ret.append(data());
- }
- return ret;
- }
- mystring operator =(char* s)
- {
- return mystring(s);
- }
- void print_n_times(int n)
- {
- std::cout<< *this * 3;
- }
- };
- int main()
- {
- mystring("Hello world \n").print_n_times(3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement