You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

39 lines
766 B
C++

#include <iostream>
#include <string>
#include <string_view>
using namespace std;
string repeat1(string_view s) {
return string{s} + string{s};
}
void repeat2(string& s) {
s += s;
}
void repeat3(string* s) {
*s += *s;
}
string* repeat4(string_view s) {
string* result = new string;
*result = string{s} + string{s};
return result;
}
int main() {
string meow;
cin >> meow;
cout << "test of repeat1:" << endl << repeat1(meow) << endl;
repeat2(meow);
cout << "test of repeat2:" << endl << meow << endl;
repeat3(&meow);
cout << "test of repeat3:" << endl << meow << endl;
cout << "test of repeat4:" << endl << *repeat4(meow) << endl;
}