Explaining the code

The preprocessor directive #include <iostream> tells the compiler to include additional functions from iostream into our program. So basically this includes additional lines of code written by others

The int main() function is the starting point which every application in c++ mus have. This shows the processor, where to start the program.
Since the function is declared with an integer as a return value, we need to return an integer at the end of the function. This is done with the return 0; statement.

Everything in between the curly brackets of main is our program / game. It consists of statements int a; and expressions std::cout << "i'm an expression"

std is a namespace and cout is a function(?). Both are provided by iostream

Privacy & Terms