October 2011
Beginner to intermediate
1200 pages
35h 33m
English
Stringbad Problems: Assignment OperatorsNot all the problems in Listing 12.3 can be blamed on the default copy constructor; you have to look at the default assignment operator, too. Just as ANSI C allows structure assignment, C++ allows class object assignment. It does so by automatically overloading an assignment operator for a class. This operator has the following prototype:
Class_name & Class_name::operator=(const Class_name &);
That is, it takes and returns a reference to an object of the class. For example, here’s the prototype for the StringBad class:
StringBad & StringBad::operator=(const StringBad &);
An overloaded assignment operator is used when you assign one object to another ...
Read now
Unlock full access