From the course: C Essential Training

Unlock the full course today

Join today to access over 23,700 courses taught by industry experts.

Vectors

Vectors

- [Narrator] A vector is a sequence container that supports random access of its elements. You can think of it as an object oriented array with a bunch of cool extra features. Vectors are fast, random access, and extremely flexible. Let's take a look. This is vector dot.cpp from Chapter nine of the exercise files. The vector is a template class. It's defined in the vector header. And here, and you'll notice we're using standard vector, so we can use the vector symbol without the STD name space, so I can use it like this. So this declares a vector object, and this vector, of course, it's a template class so I give it a type. So this is a vector of int, so it's a container that contains objects of type int. And we'll name it vector vi1. And we'll initialize it with this initializer list with 10 integer values. So what I'm going to do here is I'm going to comment out a bunch of this stuff, and we can look at this in…

Contents