[Next] [Prev] [Up] [Top]

7.0 Classes

Assignment Operator


7.15.1 Return reference from operator = (R)

The assignment operator should return a reference to the affected object. Returning void causes problems on with some compilers.

7.15.2 Guard against assigning to *this (R)

Always check against assignment to the same object. This will prevent bugs in objects that perform heap allocation in constructors.

Example: if (this == &other) return;

7.15.3 Do not make the assignment operator virtual (R)

This is almost always a mistake. Derived classes will have a different type signature (by definition).


No Title
[Next] [Prev] [Up] [Top]

Generated with CERN WebMaker

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.