Presentation is loading. Please wait.

Presentation is loading. Please wait.

Container Classes. How do we do better? Tough to delete correctly: startLocation.

Similar presentations


Presentation on theme: "Container Classes. How do we do better? Tough to delete correctly: startLocation."— Presentation transcript:

1 Container Classes

2 How do we do better? Tough to delete correctly: startLocation

3 Map Map – manages the locations, stores in array

4 Map Class Map class manages all the locations:

5 Map Details – Constructor sets up memory – Destructor cleans up

6 IntList Class that manages an array for us – Don't worry about size – Can remove items!

7 Course CourseList manages array of Course objects – Composed on Courses – responsible for them Student has array of course pointers – Aggregation – not responsible for courses

8 Details CourseList creates array on the heap, reads from file – Responsible for array

9 Details Object diagram:

10 Details Provides access to pointers to Courses

11 Student Student maintains list of pointers – Owns array, NOT courses it points to

12 Student Shared use of Course objects

13 Dynamic Array of Pointers Array of Pointers: Course* myArray[10]; Dynamic array Not of Pointers: Course* myArray; I have a memory address that is start of array Array contains Courses I am an array of 10 Pointers to courses

14 Dynamic Array of Pointers Array of Pointers: Course* myArray[10]; Dynamic array Not of Pointers: Course* myArray; Dynamic array of Pointers: Course** myArray; I have a memory address that is start of array Array contains pointers to Courses

15 Initializing Allocating array of pointers on heap: I need an array that is this size It contains pointers to Courses Put it on heap give me start address


Download ppt "Container Classes. How do we do better? Tough to delete correctly: startLocation."

Similar presentations


Ads by Google