Most of the answer is this: C ++ source code (or any high-level programming language) is stored in a text file, just as you can save an essay or note. But text characters are stored in numerical form. Therefore, when the compiler works on this data, it performs another form of crunching the number, evaluating the data and making decisions in accordance with exact rules.
If this is not clear, imagine: you have a task to read letters from a person who knows Japanese, but not English. You, meanwhile, know English, but not one Japanese word.
But suppose you have a training book that describes how to translate Japanese characters into their equivalent in English. The instruction book is written in English, so you have no problem using it.
So, even if you do not understand Japanese, you can translate all the Japanese you want by carefully following the instructions.
Here's what a computer program is: an instruction book read by a processor. A computer program is an inert thing β a sequence of instructions and data, but βknowledgeβ inside a computer arises from its programs. Programs allow the computer to do all kinds of smart things, including translating a text file containing C ++.
The compiler, of course, is a very special program, but what it does is not at all strange or impossible. Like a computer program, its "study book" as described. What he says, how to do this, is to read a text file containing the source code in C ++ and print another book statement: This output is your C ++ program in executable form.
The very first compilers should have been written to machine code. Later, old compilers could be used to write new compilers ... so even experienced programmers could rely less and less on machine code through the boot process.