Original Post
Hi! I´m reading Sams Teach Yourself C++ in 21 Days 4º Edition and I´ve got a little problem. On page 298 the author explains how to overload the increment operator using this member function:
const Counter& Counter::operator++()
{
++itsVal;
return *this;
}
He explained that he declared the reference to be constant to prevent statements like this ++++i. But I don´t see what´s wrong with such statements! Ah, one more thing: Can somebody explain me what´s the difference between returning a reference and returning a constant reference? When should I use each technique? Thanks in advance!!