The C++ standard library, often abbreviated as std, or sometimes called the C++ standard template library, or stl, provides us a set of common tools and functionality that we're going to use throughout the course. Let's look at a couple of them. The organization on the standard library is divided up into a number of separate files, and we make use of them by including them in any of our C++ programs. The most critical library that we're going to include in almost all of our programs is the iostream library. This library allows us to output data both to files as well as to the console itself, and you've already seen us use this. This is std: :cout, or console out. A really simple program using this is going to have two features to it. The first feature is, every program that uses cout must include, pound include iostream, and from there the main function is likely going to use cout. We do cout by using std denoting the standard template library namespace, and then double colon cout. At the end of the line, we see std endl, which is to denote a new line should be added to the end of our line. What we expect from this program is, "Hello world" to be outputted to the screen, when we run the program cout. Let's look at if this happens. Moving into the CPP-STD directory, I'm going to go ahead and run make to build this program. Once we build this program, I'm going to go ahead and run cout. And as you expect, it says, "Hello world." So, we see that by using cout inside of a main and including iostream, we now know how to print anything we want to the console. Let's keep going, every piece of functionality inside the standard namespace will be prefixed by the std abbreviation. The use of namespace allows us to avoid conflicts with other commonly used names. For example, we talked about a cube class, that we're going to be using throughout a number of these lectures, and we're going to want to output that cube class in our own namespace. That way, other cubes such that cube that might be included in the standard template library, won't get confused with our cube. We'll see that in a second. One thing that you may hate doing is typing std colon colon again and again and again, if you want to just type cout, we have the ability to say using std cout. By adding this line of code to our file, we can convert typing std cout into just typing cout. We can look at this in source code to see how this actually works. Here we see that we're doing the exact same thing as our old program, where we have include iostream here, and we have a main function that outputs, "Hello world" to the console. The big difference between cout and cout2, is notice that here on line 14 we're just writing cout, and here at the end of the line we're writing endl. We can do that only because we've included line 10 and 11. Lines 10 and 11 indicate that whenever you see cout, we actually mean standard cout, and whenever you see endl we actually mean standard endl. We'll go ahead and use these using statements often on. It's often common to see them used with cout because cout is so commonly used, when we use less widely used data structures you're going to see as pre-phase std colon colon more and more often. In general, you want to minimize the use of the using keyword. Because using keyword is going to make it less clear exactly what you're running, when you say std colon colon cout, everyone knows that's the standard cout, and as you write this code, everyone's going to be familiar with exactly what you're trying to do. Just like before, let's go ahead and run this program and make sure it works. Returning to the console, we see that we've already compiled the code using make, and now we can run./cout2, and cout2 just like the original cout prints out, "Hello world," everything works fine and now you know about the using syntax. We're not quite done yet, let's go ahead and revisit our cube. We can choose any namespace we want for our cube. There's no restriction on namespace besides the usual restrictions variable names, trick can't begin with a number, and other details are common across most programming languages. Looking at this program, you're going to notice a few things. First, we have a uiuc Cube. Notice that instead of saying Cube c, we have uiuc colon colon Cube. Here we have c.getLength, which is going to set the length of the Cube to 2.4. Then in line 14, we print out the volume of the Cube. So, c.getVolume is going to print out 2.4 to the third power. This is going to be approximately equal to 13, so we expect a number around 13 to be printed out. Then we see we're going to get another variable, surface area, that is returned by c.SurfaceArea. So, we're going to ask the Cube for its surface area, and the surface area of this cube is going to be a standard surface area formula. So, 6 times 2.4 squared, since 2.4 is the volume of our Cube and this number should be around 30 to 35. So, when we run this program, we're going to expect that the cube is going to be such 2.4, and then the first output we see is going to be the volume is going to be printed out to be around 13. The second thing we'll see is the surface area will get printed out and that should be somewhere around 30 to 35. Let's go ahead and run this program, main.cpp and see what happens. Again, going back to our console, we see that everything is already built, running the make process, so, we can go ahead and run./main, and./main we see the volume is indeed 13.8 and the surface area is 34. This is exactly what we expect for a Cube that has a length of 2.4. So, we see that we've been able to place the Cube into the uiuc namespace. Let's look at how we did that, and then wrap this up. As I mentioned, a Cube is a rather generic thing. You can imagine there may be multiple different Cubes in all of these C++ libraries out there. So, because of these hundreds of different Cubes that exists, we want to specify that our Cube is different than any other Cube we might have. So, instead of just calling our class Cube, we want to be able to reuse this Cube and put in a namespace that's separate it from any other namespace. As I mentioned, we put the Cube into our uiuc namespace. This uiuc namespace is added to the Cube class in the h-file, by simply surrounding everything by the word namespace uiuc and curly braces. So, you see this on line 10, and then closed on line 20. So between line 10 and 20, we have encapsulated the Cube into the uiuc namespace. That's all we need to do. We need to do a similar thing on the CPP side of thing. Notice line 10 is namespace uiuc with a curly brace, and then here on line 22 after we've finished writing all the code, we've ended the curly brace. So, to put something in a namespace, all we have to do is say, namespace uiuc, add curly braces, and we're going to do that inside of both the H and the CPP file. That's it. So, you now know how to use namespaces as well as an introduction to the standard template library. We'll start using many different data structure and standard template library coming up next. First we want to talk about memory layout, and how all of these variables you've been creating are actually stored in memory. I'll see you then.