May 2002
Beginner
320 pages
6h 18m
English
There is one area where nothing does the job better than operator overloading. You have seen the copy constructor and how it is used. As mentioned, it is typically only needed when member variables point to the heap. It is also only invoked when an object is explicitly or implicitly created as part of a copy (for instance, when a local variable is returned from a member function).
Assignment is not the same as copy creation—assignment can occur at any point in the life span of an object, not just at the beginning. For instance:
aRequest Request1(aRequest::add,34); aRequest Request2(aRequest::multiply,22); Request2 = Request1;
After the last statement, you expect Request2 to have an Operator() ...
Read now
Unlock full access