Sales_data& Sales_data::combine(const Sales_data &rhs)
{
units_sold += rhs.units_sold; // add the members of rhs into
revenue += rhs.revenue; // the members of ''this'' object
return *this; // return the object on which the function was called
}
I saw above method somewhere, and I am confused why *this
pointer is being returned? Even though without it (using void
return type) function does the same thing. I know how *this
pointer works but I was confused why *this
pointer was used in above context.
I am not an expert in C++, so can any one explain what am I missing?