Hi, I'm studying operator overloading through C++ the complete referece and I've got some questions.
In the book, the author writes this:
loc loc::operator++()
{
++longitude;
++latitute;
return *this;
}
This creates a new object and returns it.
1.Wouldn't it be more efficient to return a reference?
2.This overloads the prefix increment operator, how can I overload the postfix?
3.The author also shows how to accomplish this using friend functions.
loc operator++(loc &l)
{
l.longitude++;
l.latitute++;
return l;
}
Again, wouldn't it better to return a reference?
Is there a benefit to use friend functions here?