C++: The main function

This entry is part 3 of 61 in the series C++

We look at a simple program that basically does nothing.

In all C++ program, you need a starting main function similar to C.

The operating system such as your Windows OS will first call the main function when the program is executed.

The program below contains only one return statement wrapped inside 2 curly braces.

int main()
	return 0;


The main function is required to return type of int, which is a type that represents integers.  In this simple program, we simply return a value of 0 to it.

Series Navigation<< C++: The language
C++: Namespace >>

Leave a comment

Leave a Reply