From the course: C++ Standard Template Library

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Vectors and lists usage example

Vectors and lists usage example - C++ Tutorial

From the course: C++ Standard Template Library

Start my 1-month free trial

Vectors and lists usage example

- [Lecturer] Now, let's solve a basic problem to illustrate how to use the vector and the list container classes. Let's say we are interested in keeping track of guests who are children at a small birthday party. The simple purpose of this could be to handle the logistics for catering and party favors. We are interested in keeping track of the following information per child, the name, the gender, and the age. So let's see how the C++ STL can help. Here we have an application I have written that still needs some work. We will have to insert some lines of code to make it work for a vector or for a list. Starting at line five, we include the header files that will be useful in this application. First we have iostream and string. Next we have fstream which is for reading files. And finally, we have vector and list. In this application, we will read a whole file, which will have child entries as required and we will print out what we have read. All of this data will be stored in a vector…

Contents