Lecture9 - 1 CS11600: Introduction to Computer Programming...

Info iconThis preview shows pages 1–2. 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: 1 CS11600: Introduction to Computer Programming (C++) Lecture 9 Svetlozar Nestorov University of Chicago 1/24/2003 Svetlozar Nestorov, CS 116: Intro to Programming II 2 Outline Data member objects: containment, pointers, references An aside on references. Class member initialization: containment, references Lifetime of objects 1/24/2003 Svetlozar Nestorov, CS 116: Intro to Programming II 3 Data Member Objects An object may be a data member of another class . class Drinker { Beer favBeer; } Every Drinker object contains a Beer object ( favBeer ). Can an object be a data member of its own class? 1/24/2003 Svetlozar Nestorov, CS 116: Intro to Programming II 4 Data Member Pointers A data member can be a pointer to an object (of any class). class Drinker { Beer favBeer; Beer *favCheapBeer; Drinker *spouse; } Note that a pointer to Drinker is allowed as a data member of Drinker ....
View Full Document

Page1 / 3

Lecture9 - 1 CS11600: Introduction to Computer Programming...

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