Now, new topic. When we get a container class from the standard template library, we also get a lot of additional functionality again Recall. We're replacing a primitive container, array, with a much more sophisticated object, an object that's going to give you more flexibility. And it's going to be much safer to use. Those are the two things you're gonna buy with vector. Maybe you will take a very small amount of an efficiency hit. But in large measure, you won't. And indeed, we're going to see in a new standard, a fixed array type as a container which also Will with greater efficiency in some cases also be useful to replace the simple array type in C. So, here are some methods. V.size gets you the current size of the container that's important because containers can be resized on the go. One of the one of the most useful functions of the container is gee I can of course when I declare the container give it a size. That's frequently something that can be passed into the constructor. But I also have the ability, if I'm adding an element into the container, the container will expand. So, I don't run out of room as I would in an ordinary C array sense. I need a whole number of constructors again. Remember in our little lecture on object orientation how valuable it is to have a large number of constructors. Constructors make it convenient to initialize a data type. And they make it convenient across a whole bunch of needs. So, these are some of the critical constructors you're gonna see. And you're largely going to see them for almost all types of sequence containers. So, vector is just an example I chose vector because, vector has 90% of your value when studying the container classes. The reaction when you need a containers, a sequential container, is to pick vector. You almost should have a reason not to, you have a reason why you need a list or A deke, instead of a vector. So, a vector is going to be most of where you're gonna get your value from the template library. So, here's a constructor where you just build an empty container. And then as you add things to it, it's going to expand. Here's a container that's of a particular starting size. And here's a container in which there's not only a starting size but a value for its initialization. So, let's turn to An example I've used throughout the segment for a simple vector. Vector is the most important container class. It's the go to sequential container class. When we're using it, we have to get it from the standard library. So, in effect, this is STD vector. And we'll walk through this code and just see how effective it is. And again, largely people are replacing ordinary old style C arrays with Vector because you don't lose on efficiency and you gain a lot of safety advantages and in flexibility. So, here we're going to ask how big a vector you want. The vector itself will have it's own constructor classes which enable it to Go after the heap and obtain all the storage necessary for a particular data type. So we're asking how many elements, you could say ten or you could say ten thousand. Of course, that will affect your running time and whether there's enough storage available on your system. If it got too big, the storage gets too big, you are going to see some kind of bad allocation exception. So, we ask through standard in for how many. Here, we type something in, like we might type in 1000. And now. This is the data type so all of this stuff is a template. This is a template class. And for each template that is used you're gonna get code. So, if you need a vector for N you can get there from code for vector for double. So, keep in mind that that can affect what might be called code load. So, here you're gonna get everything to do with int, that's going to be the underlying data type that will be stored in the vector. Inter class and now you will dynamically use the constructor of one argument to build a 1000 element integer sequential data dump. And now were going to deal with one very simple thing that this program does and that is printing out that data and you can imagine that theres going to be more code so how are you going to print out the data and again with STL, Standard Template Library, the critical idiom to understand is that all its containers can be used with iterates so your logic you're going to extend an in STL like manner you have to understand the iterator logic remember iterators Are pointer type. In old C there was only a very simple primitive pointer. Iterators extend that concept. But keep the idea of pointing out where things are. It's a pointer type. Now, notice the definition, the declaration of, we're gonna declare in this forestatement a local variable. The local variable is it. It's type is tied to what it's iterating over. So, we have it taking out of the standard library a vector of so if that had been float it would have to be float there. If that had been or string it would have to be those types. And then scope resolution and then the word iterator. And so all of this is a type and this says this is the type associated with that so that the right thing can be pointed at. And then within these classes There are location primitives, begin and end. Begin is where that vector starts. Again, think of it as a generalized memory primitive, which is saying what's the location, what's the start of this vector. And then end is a sentinel. It says oh, you're at the end. You can think of it as some kind of generalized zero but this is on the sentinel. So, keep walking through, remember iterators. Can be increment and that just means get the next location. So, this four loop is all about starting at the beginning, going to the end and visiting each location once and only once. And with each location. Use it to initialize your vector. So, you're initializing your vector from standard. So, if you were to run this code from your local computer, you would see on your screen How many you would tell it how many, and then it would say the contents of. And then it would ask you to initialize and then you would have to write more code for the iterator to print what you filled the vector with onto standard out. So, you could extend this so that you can show it, processing your input and then printing out your output, that would be a nice extension, a nice exercise for you to see if you understand the whole iterator concept. Now, this iterator concept we will see in a later point can be hidden. So, an underlying mechanism but it can be hidden by either using things like the for range or by using ways to hide the complexity of the declaration with the new meaning of the key word auto.