Developing A C++ Program
Translating a C++ program
The following three steps are required to create and translate a
C++ program:
-
First, a text editor is used to save the C++ program in a text file. In other words, the source code is saved to a source file. In larger projects the programmer will normally use modular programming. This means that the source code will be stored in several source files that are edited and translated separately.
-
The source file is put through a compiler for translation. If everything works as planned, an object file made up of machine code is created. The object file is also referred to as a module.
-
Finally, the linker combines the object file with other modules to form an executable file. These further modules contain functions from standard libraries or parts of the program that have been compiled previously.
It is important to use the correct file extension for the source
file's name. Although the file extension depends on the
compiler you use, the most commonly found file extensions are .cpp and .cc.
Prior to compilation, header files, which
are also referred to as include files, can be copied to
the source file. Header files are text files containing information needed by
various source files, for example, type definitions or declarations of variables
and functions. Header files can have the file extension .h, but they may not have any file extension.
The C++ standard library contains predefined
and standardized functions that are available for any compiler.
Modern compilers normally offer an integrated
software development environment, which combines the steps mentioned
previously into a single task. A graphical user interface is available for
editing, compiling, linking, and running the application. Moreover, additional
tools, such as a debugger, can be launched.
Note |
If the source file contains just one syntax error, the compiler will report an error. Additional error messages may be shown if the compiler
attempts to continue despite having found an error. So when you are
troubleshooting a program, be sure to start with the first error
shown.
|
In addition to error messages, the compiler will also issue
warnings. A warning does not indicate a syntax error but
merely draws your attention to a possible error in the program's logic, such as
the use of a non-initialized variable.
0 Comments