 Hey everybody this is Brian and this is our third C++ tutorial. As you can see we still have the very simple Hello World application that we've made. I wanted to discuss namespaces. If you're familiar with .NET or Java you know what a namespace is. If you're not, a namespace is a way of avoiding collisions. Let's say you make a program called cat and your friend makes a program called cat. Which cat do you want to use? Well you make a namespace. That's why there's this STD or standard library. Everything in the STD namespace is part of that namespace. You can make your own C out as long as it's not in the STD namespace. Now it's kind of tedious to type STD, colon colon, and then C out. I mean what good is that? Let's actually include a namespace. So let's go using namespace STD. Now you no longer need to include that because you automatically have access to it. I can't spell today. So that's how you use a namespace in C++. Let's run this. Verify it actually works. And Hello World it works. Press any key to continue. As you can see that's very very powerful. Now instead of using the entire namespace you could go in and use individual parts of it. For example you could say you just want to use C out. I'm not gonna get that nitpicky. I really want you to focus on learning C++ and how to get comfortable with it rather than nitpicking over this class and that class. So for these tutorials we're just gonna use the entire standard library namespace. So let's actually play around with this for a little bit here. So you've learned C out, shifts bits out, or prints them out into the standard output or the DOS screen that you've been seeing. How do you read something in here? Well let's make a variable called int age and we will set that to zero. Now an int is an integer. Age is the variable name and we are setting the initial value to zero. And we're going to say Hello World enter your age. And then C in age. Now what that'll do, you notice how the arrows are in a different direction here. Think of the left side is out, the right side is in. C out. You are shifting the bits out to C out. C in, you're reading bits into a variable called age. So what this is gonna do is you have a variable called age. You're gonna say C out Hello World, C out, enter your age, and then C in age. So whatever they enter is gonna go into this age variable. And then just to see that it worked, we will C out, U entered, and age. And let's put an inline there. Remember just like Java and C sharp, you have to put this semicolon at the end here. So let's run this and see if it works. Compiling linking. Now it compiled, that's a good thing. Hello World enter your age. Well let's just enter my age 36. So as you enter 36, press any key to continue. Now let's go back here one more time. I'm doing this for those of you that are kind of staring at your screen blankly wondering what just happened. You've got your preprocessor directive, including IO stream. Within IO stream is the standard libraries C out and C in. We're using the entire standard names base so we don't have to do you know standard colon colon. We've created a variable called age, printed some stuff out, read it in, and then we printed it back out on the screen. Now I want to show you what happens if something goes horribly wrong here. So let's run the same program, enter your age, and instead of an age, let's type dog. U entered zero. What just happened? Well C++ is a very dumb compiler. And what I mean by that is it doesn't realize you didn't enter an integer. It in the background tries to cast or convert dog into an integer. Well dog's not an integer, dog's not a number. So you can't do that. So C++ just behind the scene says okay he entered nothing because he didn't enter a number. So you may get unexpected results sometimes. And when you do you have to remember that C++ is a very stupid compiler. This was developed back in the 70s. It's very ahead of its time for the 70s, but it's no longer the 70s. Now you're asking yourself why are we using it then? Because almost everything in the world right now is built upon C or C++ at some level. Even the operating system you're using, whether you're using Windows or Linux or even Google, it's C C++ under the hood. I mean that's the core of almost everything in the world right now. Trying to think if there's anything else that we forgot here. Once again remember, if you omit the system pause, the window will just appear and disappear extremely fast. I mean you know. Sorry, I forgot. Because we're C in the prompt, we'll stop and say what's your age. So we'll enter an age. When you hit enter this window is going to disappear. It's because we have exited the program. You get to return zero that just exits the program. So the DOS window just disappears. I realized I kind of rambled on. I'm trying to take this kind of slow and over inundate you with very new information here. So it absorbs in. The next couple tutorials are going to go a little bit faster. So practice shifting things out and reading things in and see the different results you get. This is Brian. Thanks for watching. I hope you found this video educational and entertaining.