I am trying to understand how to implement a class-object. I want to know what is main difference between the following two class assignment operators.
Point Point::operator=(const Point & p)
{
if(this == &p)
return *this;
m_x = p.m_x;
m_y = p.m_y;
return *this;
}
And this one
Point & Point::operator=(const Point & p)
{
if(this == &p)
return *this;
m_x = p.m_x;
m_y = p.m_y;
return *this;
}
I can see, the latter one returns a reference to an object but I don't see any practical difference. For example, both of them works fine, when I try to do something like this:
Point point2, point3;
point3 = point2 = point1;