diff options
| author | Divay Prakash <divayprakash@users.noreply.github.com> | 2019-08-03 00:08:50 +0530 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-03 00:08:50 +0530 | 
| commit | bc776d9af17aa62fea676dbc3b9c4d73999bef98 (patch) | |
| tree | 67c5b46971275e4fa954d8d876713a8d39be667b | |
| parent | 0ad160aba62b0ec8fd3a7c07c793ab6cd388230b (diff) | |
| parent | 696cbc66bed9971d3152cd9fd24e268caf3aec99 (diff) | |
Merge pull request #3554 from codesoap/master
[c++/en] Add more explanation to the += overloading example
| -rw-r--r-- | c++.html.markdown | 4 | 
1 files changed, 4 insertions, 0 deletions
| diff --git a/c++.html.markdown b/c++.html.markdown index 80ad3a6c..fc9f6ce2 100644 --- a/c++.html.markdown +++ b/c++.html.markdown @@ -553,10 +553,14 @@ Point Point::operator+(const Point& rhs) const      return Point(x + rhs.x, y + rhs.y);  } +// It's good practice to return a reference to the leftmost variable of +// an assignment. `(a += b) == c` will work this way.  Point& Point::operator+=(const Point& rhs)  {      x += rhs.x;      y += rhs.y; +     +    // `this` is a pointer to the object, on which a method is called.      return *this;  } | 
