Default Move Semantics and the Rule of Zero

Learn about the automatically generated copy-assignment operator.

As with the copy-constructor and copy-assignment, the move-constructor and move-assignment can be generated by the compiler. Although some compilers allow themselves to automatically generate these functions under certain conditions, we can simply force the compiler to generate them by using the default keyword.

In the case of the Button class, which doesn't manually handle any resources, we can simply extend it like this:

Get hands-on with 1400+ tech skills courses.