How C++ works

Shaila Nasrin
Learn Coding Concepts with Shaila
3 min readOct 12, 2019

--

The basic workflow of c++ code is: source file-> compiler -> executable binary file. But how do we get to the executable binary file from source code?

Let's see a c++ code first:

What is in the Source file?

The first thing we see in the above code is: “#include<iostream>” this is a preprocessor statement. Whatever starts with “#” is a preprocessor statement. When a compiler gets a source file, it preprocesses all the preprocessor statements. Then we have “include”, it finds the file “iostream” and takes all of its contents and pastes them into the current file. This is called a header file.

Then we have the “int main()” function. It is the entry point of the application. So, when we run the application the computer starts executing code that begins in the main function. When the program is running the computer executes the lines of code in order. The first thing that will be executed in the above code is “std::cout << “Hello world” << std::endl;” and then “return 0” , as the return type of main() function is int, we are returning 0 but if you remove this return statement our…

--

--