I have some functions which perform string transformations. Since they use the original string, but return a copy of the modified string, what is better style?
Code:string transform1(const string& s) { //uses const reference
string s2 = s; //make a copy
//do some stuff on the copy
return s2;
}
string transform2(string s) { //passed by value
//do some stuff on the copy already passed in
return s;
}