
Help: inline char const* const& max(char const* const &a, char const* const &b)
Indeed. It makes no sense to pass a pointer by reference (and have another
level of indirection) unless you're planning to change it, which is not the
case here. What book is that, out of curiosity?
Quote:
Quote:
> > Hi, My Friends,
> > I'm reading a book about c++ . Following is an example function in the
> > book.
> > //maximum of two C-String
> > inline char const* const& max(char const* const &a, char const*
const
> > &b)
> > {
> > return strcmp(a,b)<0?b:a;
> > }
> > There is no compile error on this function. But I can not understand it.
> > It return a pointer or a reference? The argumemts are pointer or
> > reference? what do these const mean?
> They are all references to pointers. It's not particularly clear what
the
> author is trying to accomplish here. Nothing is gained over passing by
> value here (it actually might end up being less efficient).