[0] Unlike Java, the file-name of *.cpp doesn’t has to be identical to the class name. “File” for C++ is more like a simple container. And the suffix of the file “.cpp” or “.hpp” tells the compiler in which form this file is.
[1] One *.cpp file doesn’t always corresponding to one translation unit.
Some *.cpp file could include several other *.cpp files, but since the compiler is fed with one single *.cpp file, there will be ONLY one translation-unit.
[2] Unreadable Machine Code
[3] In order to see what’s happening here. We can convert *.o to *.asm — a readable Machine Code format.
[4] This executable file contains all the object files generated by the compiler and has all the necessary Machine Code.
It is important to know what happened in Preprocessing-Compilation-stage and Linking-stage. Because when you debug your code, errors occur in Preprocessing-Compilation-stage has the error code start with “C”, errors occur in Linking-stage has the error code start with “LNK”. For example:
- error C2039: ‘cout’ is not a member of ‘std’ -> fix with “#include <iostream>”
- error LNK2019: unresolved external symbol -> Linker cannot find what it need