Summary
In this hour you learned about operator overloading.
The copy constructor and operator= are supplied by the compiler if you don't create your own, but they create a shallow copy of the class. In classes in which member data includes pointers to the heap, methods must be overridden so that you allocate memory for the target object.
Almost all C++ operators can be overloaded, although you want to be cautious not to create operators whose use is counterintuitive. You cannot change the arity of operators, nor can you invent new operators.
The this pointer refers to the current object and is an invisible parameter to all member functions. The dereferenced this pointer is often returned by overloaded operators.
Conversion operators enable you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access