
Keith B. answered 09/28/19
Software Engineer and Math Geek
You're right, the compiler is capable of producing these three basic items for free, but there's a limit to how well the work. The compiler "does it's best" to initialize the member variables and clean up when the object goes out of scope. And it tries very hard to copy everything when doing an assign, and truth for simple classes this works fine. But as you scale up your class definitions, it starts to get shaky - add a simple pointer to the mix and this house of cards falls right down.
Good coding practices says you should always define these three, never let the compiler provide what is referred to as a "shallow" method. Do otherwise can lead to undefined results.
When we start to talk about comparison, however, it begs the question -- just what exactly determines that two objects of the same class are equal? Do you honestly want it comparing each and every member by default, when all that really needs to be checked is the ID? Let's not even discuss if the class has pointers.