HISTORY OF C++
PROGRAMMING LANGUAGE
It is difficult to program in machine code and early
computer pioneers soon developed the high-level languages which make the
programming easier than before. One of these high-level languages is
C++.
The C++ programming language was developed by Bjarne
Stroustrup(Bell laboratories) in early 1980s.
TIPS ON STANDARD LIBRARY
Using C++ Standard Library functions and classes instead
of writing your own versions can improve
Program performance, because they are written carefully
to perform efficiently. This technique also
shortens program development time.
THE PROCESSES OF
CREATING A PROGRAM
The processes of
creating a program include;
v Write
the program in a computer language that humans can read and understand (like C++).
v Save
the program in text files.
v Run
the source code files through a program called a compiler to generate object code
for the target computer.
v Run
the object file through a program called a linker to produce an executable
image
Three programs are used to translate
your source code into an executable file that the computer can run. These
programs are in their order of appearance:
§ Preprocessor
§ Compiler
§ Linker
PREPROCESSOR
The preprocessor
is a program that scans the source code for preprocessor directives such as
include directives. The preprocessor inserts into the source code all files
included by the include directives.
COMPILER
The compiler is another program that translates the
preprocessed source code (the source after the insertion made by the
preprocessor) into corresponding machine language instructions, which are
stored in a separate file called an object file, having an obj extension. There
are different compilers for different programming languages, but the purpose of
the compiler is essentially the same, the translation of a programming language
into machine language, no matter which programming language is involved.
LINKER
While the object file has machine language instruction,
the computer cannot run the object file as a program. The reason is that C++
also needs to use another code library, called the run time library, for common
operations, such as the translation of keyboard input or the ability to
interact with external hardware such as the monitor to display a message.
The linker is a third program that combines the object
file with the necessary parts of the run-library. The result is the creation of
an executable file with an .exe extension.
TYPICAL C++
DEVELOPMENT ENVIRONMENT
Phase: Creating a program
Phase 1 consists of editing a file with an editor program
(normally known simply as an editor).
You type a C++ program (source code) using an editor, make any necessary
corrections and save the program on a secondary storage device, such as your
hard drive. C++ source code file names often end with the. Cpp, .Cxx, .CC or .C
extensions.
Phase 2 And 3: Preprocessing and Compiling a C++ Program
In phase 2, the programmer gives the command to compile
the program. In a C++ system, a preprocessor program executes automatically
before the compiler’s translation phase begins. The C++ preprocessor obeys
commands called preprocessor directives, which indicate that certain
manipulations usually include other text files to be compiled and perform
various text replacements.
Phase 4: Linking
Phase 4 is a called linking. C++ programs typically
contain references to functions and data defined elsewhere, such as in the
standard libraries or in the private libraries of groups of programmers working
on a particular project. The object code produced by the C++ compiler typically
contains “holes” due to these missing parts. A linker links the object code
with the code of missing functions to produce an executable image (with no
missing pieces). If the program compiles and links correctly, an executable
image is produced.
Phase 5: Loading
Phase 5 is Loading.
Before a program can be executed, it must first be placed
in memory. This is done by the loader, which takes the executable image from
disk and transfer it to memory. Additional components from shared libraries
that support the program are also loaded.
Phase 6: Execution
Finally, the computer, under the control of its CPU, executes
one instruction at a time.
Programs do no always work on first try. Each of the
proceeding phase can fail because of various errors. For example, an executing
program might attempt to divide by zero (an illegal operation for whole-number
arithmetic in C++). This would cause the C++ program to display an error
message. If this occurs, you would have to return to phase-1 for editing, make
the necessary corrections and proceed the remaining phases again to determine
that the corrections fix the problem(s).

1 Comments
Great keep it up
ReplyDelete