> -------- Original Message -------- > Subject: RE: object-model: Return by value, reference or pointer? (or > something else?) > From: "Bolstridge, Andrew" <andy.bolstri...@intergraph.com> > Date: Thu, October 14, 2010 5:24 am > To: <dev@subversion.apache.org>
[snip] > Personally, I would stick to just returning a string, or if it is > essential to return a null value, return a string and an null indicator > - your choice whether that's best as a pair, or an out parameter. I > would not inherit from std::string, nor would I throw an exception (not > that anyone's yet suggested that - we're not C# or Java programmers > after all :-) ) I like that - and the out parameter is actually the place to use a pointer so callers can decide whether or not they care about the difference between null and empty: std::string getAuthor( bool* isNull = 0 ) const { /* ... */ } Callers who care about null-ness can check for it with little more effort (and a slightly clumsier API) than an isNull() method.