 Hello everybody, welcome back to the C++ programming language tutorial, I'm Rudolf Van Nel, and this is the very very first video. This is the first time we're going to actually going to put our fingers to the keyboard and write some code. So, I've got a blank document open in my text editor sublime text, I'm going to go ahead and save it in my home directory under Cwork, and I'll just call mine 01 underscore hello world dot cpp. Cpp is the file extension that we'll be using, I know you can't really see that, but it is a dot cpp. I'll save this and now for to open it up or save it to something else, you can see it's 01 underscore hello world dot cpp. Cpp is the typical file extension for C++ programs, and that's what we'll be using. Okay, now that we've got our file saved, let's go ahead and start to type, start to write some code. The first thing that you'll typically want in your bare bones essential minimalist program is a hash or a pound symbol, and that is a symbol that kind of refers to a preprocessor directive. Now, those are two fancy words you, if you have not programmed in C++ before any other hardcore language, you might not know preprocessor directive. Well, a directive is kind of a command or instruction or something to do, it's like a direction or I think whatever. Don't trust me on any of this by the way, I'm not a professional, just a simple high school student experimenting with programming and code. Regardless, this preprocessing directive will be a command that is understood and implemented through preprocessing. That's what the preprocessor is. It will process your code before it's compiled. And so what we would do here is we would kind of use this pound symbol or this hash with include. And that keyword, look, you can see it lit up, it's a different color now because the text editor knows it. Okay, that's a specific keyword that C++ is used to. We're going to include some other code that other people have written or simple libraries and that sort of thing. So that's what this hash tag means, it's a preprocessor directive to include, include is the command. And now we'll use the less than and greater than symbols, the waka waka, as you may know it called. And we're going to include something called IO stream. That's IO and then the word stream. Now, this I stands for input and this O stands for output. This is the typical input and output stream that C++ normally uses. Now we're actually going to start to write our code. I'll save this file. And the first thing that I'm going to type is int. Now you may be wondering what the heck does that mean? But it is a data type and we'll get into more of this very, very soon. But data types are kind of the kinds of information that you can use in your programming language. Most of you may very well be coming from Python. Python is an incredible and an awesome programming language to start with if you're going to learn programming. And that doesn't typically declare what kind of information or your data really is, what type that it is. C++ does that, it has a static type setting. Not as opposed to dynamic type setting that you might be used to in Python. So if we have an int, what we're going to be building next is a function. And this is the main function, which will run automatically when our program runs. It's just simple, the word main. And all functions, I'm sure you are used to this, at least hopefully, have parentheses. We're not going to supply any arguments of just yet, so we'll leave inside the parentheses empty. But next we have to define a block of code. And we don't use a colon like we're used to in Python to do this and just have white space. That's not how it works in C++. In this case, it uses code blocks that are defined with the braces or brackets. Honestly, I don't know, it's been a while since I've brushed up on these. But you have your opening one, it's a curly brace, it's a curly bracket. And those are what you use to denote a block of code. Now it's a good idea to allow for some white space, make some new lines and some indentations so you can actually separate your logic from one subset to another. And then we'll actually start to write. Now, the next thing that we're going to do is type in STD. Now, I know what you're thinking. This is not actually an STD, it is not a sexually transmitted disease. It is a namespace and that refers to kind of a group of things that you can use in your code in C++ that have specific names. And C++ has namespaces so it doesn't ever get confused in case you ever have any things that have the same name, like variables or functions or that sort of thing. Now, normally we would use this with a tag using namespace STD right up at the top here. And we can do that, of course, and I'll actually do that in the next tutorial. But for now, if we're writing this simple bare bones and minimalistic code that all it literally does is say hello world, I'm not going to bother to include all of that when we're just going to be using one part of it. So, the way to receive things from a namespace in C++ is by following the namespace name with two colons. I'll make some space there so you can see that. It's just simply two colons and then we'll actually refer to what it is that we want out of there. Now, we've included iostream so we're actually going to use one of the streams, input or output. Well, in this case, we're displaying something to the screen so it should be pretty obvious we just want output. And the way that that's denoted is C out or count. You can say it however you'd like, but the operator to actually use this C out kind of command or what it is that we're using here is two less than symbols. It's like it's outputting this. It's C out and then it's being thrown that way in that direction. And now, we'll use two quotation marks to denote that we're using a string here or some text. You might be used to that data type if you've been with Python or other programming languages. And we will simply say, hello world! Awesome. Now, let's continue this. I'm going to use the operator one more time and we're actually going to be including STD for sexually transmitted disease. And we'll use the two columns as our namespace kind of collector or operator so we can use things from it. And now, I'm going to use the special keyword called ENDL. And that means end line. So that's going to typically create a pretty standard new line key. We could, of course, use the escaped N at the end of our string. But just to be somewhat cross-platform, at least with that ID in mind. It's not really cross-platform. We can just use STD colon NL for end line. Now, I've included a semicolon at the very end of this line. Now, because C++ is a language that is procedural and runs its code command by command, statement by statement, it has to know when the end of one statement is. Since this is all going to be eventually scrunched up and kind of become machine code at the very end of its life cycle, once everything is compiled, it actually has to know where everything ends. And that's why we use semicolons at the end of every line. If you're not used to that style, you're going to have to get used to it in C++. And don't worry, you're a compiler or debugger will repeatedly remind you in case you forget any semicolons. And there we go. I believe we can run this code just the way it is right now. In fact, let's go over to our Terminator or our Terminal. And now that we are already in C work, at least I am, there's Hello World right there. I can use G++ with the input file, 01HelloWorld. If I run this just now, okay, it does compile. And also, I can see that it's created this a.out file. Now if we run that with dot slash a.out, it says Hello World. And that's awesome. Okay. So that is essentially a C++ program in its bare simplest form. There is one more thing that you would normally tack on to the end of any C++ program. And that is normally return zero. Every function, or at least most functions, will return something. They will return a value that is of the same type of the type and data type that you've supplied for this function. So for int main, we're obviously going to return an integer or an int. Now that's what this zero is. Normally, your program, your shell, your operating system will have specific values for what a program, what kind of signal your program will send if the code and if the program was successfully executed, if it did everything that it wanted to do. Now this is zero. Zero means a successful exit code that we did everything that we wanted to do and we've happily reached the end of the program. That's what this return zero will essentially do. If I show you this code without it, if I compile my program again, then I just run the code. We have LO world, and this is going to be a little bit of bash that you might not be associated with. But I can run echo, the dollar sign to access a variable and the question mark to access the last command. And it is zero by default because we have successfully reached the end of the program. But it might be a good idea to explicitly return this. If I instead return one, then if I compile my program, if I run eight out out one more time, and now I check for what the exit code was, it is zero. We can actually set this up to be anything we want it to be any number because we set up this integer over here, but we normally see zero right here. So for now, and just as good practice, let's always include this return zero at the end of our code. Compile this program, run it, check out the exit signal. Sorry. It is zero. Cool. There it is. There's our simple small program. All it does is say hello world, and that's the traditional kind of cultural welcome to programming. This is everything as your fingertips. That's the normal routine anyway for a learning programmer to say hello to the world. And man, we've got a lot of potential here. We've got a lot of things to cover, things to learn, and we just started with C++. Thanks for watching everybody. I hope you enjoyed this. I hope you are actually able to understand some of the things that I mentioned as we slowly and very, very slowly went through this code. It doesn't do much at all, but hey, it's a world waiting for us. Hello world. I might be going through these next videos rather quickly because I'm sure most of you are used to these concepts and programming, especially me coming from Python and lots of other languages, and especially after having so many Python series out, this should be old hat to you guys. Thanks for watching though, and I'll see you in the next tutorial. Bye.