RulesOfThumbForOperatorOverloading

RulesOfThumbForOperatorOverloading - Chapter 14: Some Notes...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 7

RulesOfThumbForOperatorOverloading - Chapter 14: Some Notes...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online