Explore the solution to the challenge as well as alternative ways a correct solution may have been produced.
- [Eduardo] Here is my solution.…This is the starting file which has…the birthday party logistics application,…and we will start by writing the required functions.…Let's start with the get_guest function in line 72.…It will return a Boolean value…and its parameters will be first a pointer…to our container of the class my_container.…
Then the index as an integer.…And finally the return value…will be a reference to a guest object.…Let's call it ret, as in return.…Since I want this code to work for both…a vector analyst, I will use an iterator…that will go through the whole container sequentially.…I will use the auto-specifier for this in line 73.…
My iterator will be called it.…Now the for loop will increment the iterator…until it reaches the desired index.…Notice how I increment the i variable and the iterator.…Next we have to validate that the iterator…hasn't gone past the end of the container.…
If so we will report failure.…When the for loop ends the iterator…is at the desired position…and so we can return just that.…
- Why the STL is important
- Containers and iterators
- Vectors and lists
- Stacks and dequeues
- Associative containers
Skill Level Advanced
1. The Standard Template Library
2. Vectors and Lists
3. Stacks, Queues, and Deques
4. Associative Containers
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.