Lefteris Laskaridis said:
Can anybody tell me what is the use of specifiying a function argument as
char const* const& instead of char const*?
for example:
char const* const& function( char const* const& someString )
-
Thanx
There is no point. The person who wrote the function probably thought that
returning a reference would be more efficient than just returning a pointer.
However, it is highly unlikely that a reference is easier to transfer than a
pointer, since the obvious implementation of passing by reference is just to
pass a pointer to the object. So whoever wrote this was probably just
confused.
Worse, returning by reference requires that function returns a reference to
an object outside of the function, which hurts maintenance flexibility. It
is hard to imagine an occasion to use this rather than just:
char const *function (char const *someString);
HTH