Why is the assignment operator implicitly defined?


Default Constructor, Copy Constructor and Destructor are very important and I understand why C++ implicitly defined them. Just think about function arguments that should be copied, local variables that should be destructed and objects that should be construct-able even if you don't say how to construct.

But why do we need the copy assignment operator implicitly defined? Is it really a must to be able to do a = b? It is not game changing, right? Any strong reason I don't know?

... why do we need the copy assignment operator?

Simply, to support assignment semantics. These are not the same as copy construction semantics.

Foo f1;
Foo f2(f1); // copy...
Foo f3;
f3 = f1; // assignment...

They are similar, and often implemented in terms of one another, but not the same.

Why would they all be implicitly defined?

To support and mimic the C-style value semantics. So that user defined types can support the same semantics as the built in types.

Side note; IIRC, there has been some deprecation of rules here with the onset of move semantics...