Why do you have that operator at all?
The compiler would create for your struct a proper copy assignment operator by default.
What is the type of
Queue.end()?
What is the type of
Queue.back()?
You wrote the code. Therefore, you should know.
The compiler's error message shoould show the type of arguments in the call and types of known overloads of '='. That can be cryptic.
Your operator. When we write
two = one; we expect the
two to change and become a copy of
one.
Your operator will never change the
two. It is
const member function. What your operator does is creation of a temporary object
lhs, whose value you do set.
When we write
three = two = one; we expect it to do the same as
1 2
|
two = one;
three = two;
|
Yours does not. It does not modify the two. It does return a copy of one, but your
three = one; does not modify the
three.