You have not declared an assignment operator taking a right-hand operand of type Box
, so the compiler has no other option than to use its generated default assignment operator.
You also have no return
statements in your assignment operators, by the way.
Maybe you meant to write:
Box& operator=(const Box& other) {
value = other.value;
return *this;
}
Box& operator=(Box&& val) {
value = other.value;
return *this;
}
Notice that an rvalue reference to const
would make little sense.