You'll find that in most cases, the usage shown here is adequate. The vector class is a template , which means that it can be efficiently applied to different types. That is, we can create a vector of shape s, a vector of cat s, a vector of string s, etc. When you do this, you end up with a customized vector that will only hold string objects, and you'll get an error message from the compiler if you try to put anything else into it. There are many more member functions in vector and many more containers in the STL, but you'll be surprised at how much you can do just knowing about a few simple features.
Arrays are aggregates , which mean they consist of a number of elements clumped together.
The distinguishing characteristic of an array is that these elements are the same size and are arranged to be one right after the other. With that in mind, you can now see a program that uses vector . However, these string objects are pushed onto the back of the vector v . Once the while loop completes, the entire file is resident in memory, inside v . The next statement in the program is called a for loop.