One example where reference ought to be used instead of pointers:
enum day
{
Mon, Tue, Wed, Thu, Fri, Sat, Sun
};
day d;
day *operator++(day *d);
The operator ++ can be invoked using ++&d
, which does not look that intuitive.
One big catch here is that all overloaded operator functions must either be a member of a class, or have a parameter of type T, T &, or T const &, where T is a class or enumeration type. So, in this case
day *operator++(day *d);
won't even compile.
It works fine using reference i.e.
day &operator++(day &d);
which can be invoked simply as ++d;
Here is a nice article from where I got this example.
cheers