lecture20 - Last Time: * * * * Double-ended lists...

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

View Full Document Right Arrow Icon
Last Time: * Double-ended lists * Doubly-linked lists * The "at-most-once" rule * Templates Today: * Containers-by-reference vs. by-value ++++++++++++++++++++++++++++++++ If you've been paying close attention, you'll notice that we've been careful to specify whether our templated List contains objects inserted by reference, or inserted by value. There are several reasons for this. The most important such reason is that there is a fundamental difference between containers-of-objects and containers-of-pointers---the latter are subject to two broad classes of potential bugs: * using an object after it has been deleted * leaving an object orphaned by *never* deleting it We have introduced the "at-most-once" invariant to avoid the vast majority of these sorts of bugs. The invariant has a simple statement, plus three rules-of-thumb to ensure that it is maintained: at-most-once: a pointer to any specific object can exist in at most one container object at any point in time. The three rules were:
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

lecture20 - Last Time: * * * * Double-ended lists...

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

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