This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Chapter 14: Some Notes on Operator Overloading Operator overloading • C++ allows for operator overloading. • What is operator overloading. • Handles classes like primitives. • Integer class... Assignment Operator • Memberwise assignment is a danger if pointers are involved. • Assigment operator for assignment statements. • Default one issued if no explicit one is created. The this keyword • Special pointer pointing to the object on which a function was called. • Can be used for clarity. • const, cannot be made to point to something else. • implicitly applied. Anatomy of an assignment operator: • Why reference parameter? More e cient, no additional objects created. • Why const parameter? Avoids altering of other. Can then also pass const others... • Why return value (reference)? Chaining of assignment statements. No additional objects created. • Why check for self assignment?...
View Full Document
This note was uploaded on 02/27/2012 for the course IT 101 taught by Professor Unsure during the Spring '11 term at University of South Africa.
- Spring '11