Generalizes passing by reference and returning by value of string arguments in C++