Example code:
class Thingy
{
public:
void doStuff(std::string&);
std::string doStuff();
};
void Thingy::doStuff(std::string& str) {
str = "stuff";
}
std::string Thingy::doStuff() {
return "stuff";
}
int main(int argc, const char* args[])
{
std::string name;
Thingy thingy;
thingy.doStuff(name);
std::cout << name << " " << thingy.doStuff() << std::endl;
}
Specifically for strings, is either approach more efficient, and is that efficiency "worth it" to warp the readability or consistency of your code? (For example, I'd prefer not to create the name variable if I don't have to)
And is the fact that this is (at the end of the day) a string constant relevant to this discussion?