What\'s better as default, to return a copy (1) or a reference (2) from a getter function?
class foo { public: std::string str () { // (1)
My rule of thumb is to return a copy for simple basic datatypes such as int, string etc. For a bit more complicated structures where copying may be costlier (like vector you mentioned) I prefer to return a const-reference.