Programming Language: C++

Software Tools That You'll Need

Before you can start creating your own applications you'll need several software tools.
These tools will be used to help you write your program by providing syntax highlighting, auto-completion suggestions, error reporting and other information that is useful when building your own applications.

The core tools used in C++ programming are:

  • Text editor: This can be any word processing application that can save documents in a plain text format.
    (plain text format is unable to store size, font, colour, images, hyperlinks, etc.)
  • Compiler: This is an application that can read files written in C++ (otherwise known as parsing) and generate our application. This is done through a number of sub-operations detailed further in the points below.
    • Pre-processor: In C++ there are a number of instructions intended for the pre-processor. These instructions will be interpreted and the compiler will generate intermediate source files.
    • Build stage: Here the intermediate C++ source files are now parsed and converted into assembly files, then an assembler is run to convert these into pure machine code which is stored in object files .o or .obj.
    • Linker: This stage takes the object files, strings them together, and ultimately produces the application binary. The application binary will usually be in the form of one or more .exe, .dll, .so, .run or .dmg files.

You may choose instead to use a tool known as an Integrated Development Environment (IDE). This is an application that aims to combine the text editor (which can also include powerful text editing features), the compiler, and additional development tools, into a single program.

All of our C++ tutorials will adhere to the C++11 standard (or earlier) and will work on any operating system where supporting compilers are available.

For information on how to install and configure your software packages or IDE please refer to our articles on Installing And Configuring Your Development Tools.

Structure of a C++ Program

Executable applications designed using C++ are made of source files and header files, these files will be parsed and converted to an executable binary using your compiler. An application may also include any number of resources such as images, audio files, text or data files, etc.

Header files are used to give the compiler a basic idea of how our program is structured, what actions it can perform, and what data it contains. For all following tutorials we will place our pre-processor instructions, function declarations and variable declarations (these terms will be defined in later articles) within appropriately named header files (except for applications simple enough to be contained within a single source file).

Source files hold line-by-line instructions written in C++ to be executed when the application is opened.

C++ header files can use the file extensions (in order of least to most common)  .hh, .h++, .hxx, .hpp and .h. Note that some libraries do not use a file extension for their header files, though we advise always using .hpp or .h within your own projects to prevent confusion.
C++ source files can use the file extensions (in order of least to most common) .cc, .c++, .cxx and .cpp.

Entry point

Every program needs a place to start, this is most commonly referred to as the entry point. Depending on the programming language being used the entry point may differ. Some languages simply start at the top of a main file and work downwards, others require that we explicitly specify where to start our program. In C and C++ we must specify where our program starts using the main() function (more on this will be covered in the Hello World tutorial).