The usual form returns a reference to the target object to allow assignment chaining. Otherwise, it wouldn’t be possible to do:
Foo a, b, c;
// ...
a = b = c;
Still, keep in mind that getting right the assigment operator is tougher than it might seem.
More Related Contents:
- Why must the copy assignment operator return a reference/const reference?
- Why cannot a non-member function be used for overloading the assignment operator?
- Overloading assignment operator in C++
- C++ why the assignment operator should return a const ref in order to avoid (a=b)=c
- New to programming: How to call a structure’s variables in a function and then update them? (C++) [closed]
- Does my overload of operator
- What is The Rule of Three?
- Operator overloading : member function vs. non-member function?
- virtual assignment operator C++
- When to Overload the Comma Operator?
- Making operator
- Using assignment as a condition expression?
- Placement new and assignment of class with const member
- Operator Overloading in C++ as int + obj
- Simplest way to determine return type of function
- How do I prevent a class from being allocated via the ‘new’ operator? (I’d like to ensure my RAII class is always allocated on the stack.)
- C++ template friend operator overloading
- operator= and functions that are not inherited in C++?
- difference between global operator and member operator
- Return Type Covariance with Smart Pointers
- What does “operator = must be a non-static member” mean?
- Using `std::function` to call non-void function
- Overload operators as member function or non-member (friend) function?
- What does an ampersand after this assignment operator mean?
- How could comma separated initialization such as in Eigen be possibly implemented in C++?
- Where should non-member operator overloads be placed?
- Template assignment operator overloading mystery
- How can it be useful to overload the “function call” operator?
- How to overload operator==() for a pointer to the class?
- friend declaration declares a non-template function [duplicate]