Welcome to the C++ Tutorial



Before we begin our programming tutorial, let us quickly look into the important features of C++ 

  • It was developed by Bjarne Stroustrup in the 1980s as a successor to the C language.
  • It is an object-oriented programming language as it uses classes and objects.
  • C++ is used in areas such as gaming and systems like JavaScript's V8 engine, Spotify, and Youtube all use C++.

      Now we will quickly look into the basic syntax of C++, or else also known as C++ boilerplate code.  

 
#include<iostream>
using namespace std;
int main()
{
return 0;
}

Now let us look into exactly what this boilerplate code exactly means:


1.#include<iostream> -- When we write #include we are actually telling our compiler to include the header file named iostream into our program.This iostream is an input-output stream that contains basic C++ functions such as cin(used for taking user input), cout(for printing to the console).So by writing this we are actually including these header files into our program.

2. using namespace std -- when we write this into our program we are telling our compiler to use standard namespaces. This allows us to write our programs in an abstracted way and we do not need to specify the namespace for every outside object, variable, and function we call.If we do not use this we would have to use the (std::) code before every input and output code we write.

The benefits of writing namespace can be illustrated as follows:

  • Syntax without using namespaces :

            std::cout << "Hello world." << std::endl;

  • Syntax when using namespaces :
   cout << "Hello world." << endl;

As we can see we would not need the scope resolution operator(::)  if we are using the namespaces in our program

3. int main() - it is called the main function and it is from here that the actual execution of our program begins. Our code runs by first entering into the main function and then executing every line of code, therefore.

4. return 0 It is completely optional to write this piece of code as our program would still run perfectly even without it. It is used as an indication that our program will execute successfully and indicates the end of the main function.