2. Introduction to C++; Absolute beginner skill level; Breaking down Hello World; Fundamentals :: Videos



Description:


This is part 2 of the programming in c++ series for you.
In this video we will break down the basic hello world program that we wrote earlier into different parts and see what every part is doing. This should be pretty straight forward. I just want you to see what everything is doing and how are all those parts important. So, if you are having difficulty understanding just go with it for a moment and you should be able to understand it as we go on with the programming.

Here's what we did:

#include <iostream>

using namespace std;

int main()
{
 cout << "Hello World" << endl;
}



We have a hello world program. Let's break this code down
Anything that starts in C++ with a hash(#) is called a preprocessor directive. Those are the commands that are processed first even before the actual program is compiled by the C++ compiler. In our case we have asked to include a file called "iostream"."iostream" is a standard library file for c++ that will define the commands to have standard input and output for the program.

Preprocessor Directives
Anything that you use after include is called the header file and it is enclosed in smaller than and greater than sign if it is standard library file. Or if you are including a file that you wrote and is not standard library file you can include them within a " ". For example

#include "myfile"

Comments
The comments begin with // or have /* and end with */ and do have any effect on the program whatsoever. It is for you and other programmers to read your program.

Main Function
A C++ program will always have a main function that returns an integer. Returning 0 means a successful completion of the program. Main function is normally written with syntax

int main(){}

. All the functions are defined in that manner. Anything between "{" and "}" is called the body. Between "(" and ")" you will have different variables and we will talk about those later on.

cout and endl
"cout" is a standard output command for C++. With "cout" you can put your output to standard output which is mostly your computer screen.
"endl" is written in the end to say that the line ends here. "Whatever you do or write, write in next line". That line defines an statement. And statements always end with a semicolon.

And very very important: C++ is a case sensitive language!!!! Smaller letters and capital letters have their differences. Writing cout and Cout means different meanings.

Thank you for watching video! Will see you in the next video.


Comments:

Please login to post your thoughts!
 

There are no commnets yet!
 

Login

Username:
Password:
Don't have an account?
Register here
Register

Subscribe Youtube



Network DigitalStage.org


Some interesting stuffs