The compilation operation consists of translating a program written in a complex and human-readable language like C++, C, PASCAL, ADA, etc. into assembler code, which can be directly understood by the CPU.
Practically, a compiler is itself a program which reads source files written by a
human, for instance in C++, and generate object files which contains assembler
code.
Why using a language like C++ and a compiler instead of writing assembler :
1. CPUs have different assembler codes, so using a compiler allows to use the
same language on different CPUs ;
2. compilers are able to spot in your program things that can be rewritten
differently and more efficiently ;
3. languages like C++ or Java allow to manipulate complex structures of data
in an abstract way.
Finally, to write a C++ program, the programmer first has to write a file con-
taining the C++ source code itself. Then, he runs the compiler, giving the name
of the source file and the name of the object file as parameters. The resulting
object file can then be run as a program itself.
![]() |
Role of compilation in C++ |
Read More About Compilation :-The compilation process