I donnot understand the use of return *this "as a whole"

Hi, I cannot figure out what the below part of my book I'm reading actually does.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//this function supposed to mimic the += operator
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
}

int main()
{
//...sth sth

Sales_data total, trans; 
//assuming both total and trans were also defined...
total.combine(trans);
//and here the book says:
//we do need to use this to access the object as a whole.
//Here the return statement dereferences this to obtain the object on which the
//function is executing. That is, for the call above, we return a reference to total.
//*** what does it mean "we return a reference to total" !?
}


I should say that I have previously a little knowledge in C# and don't really understand how exactly "return *this" affects total object.
Well in this case I'd be confused too because the return value of combine() isn't even being used. But the poit of returning *this as a reference in this case if you could then call another method like so:
total.combine(trans).combine(something_else);
and so on.
Topic archived. No new replies allowed.