Each .cpp file is compiled separately. The preprocessor will expand all includes and macros
and then treat that .cpp file that’s made a a single independent translation unit.
They are only merged at the linking step by linker.
This is why headers are needed as older compilers cannot just inline a lot of code and compile it. Headers give a way to define and say “this exists, don’t worry, you can just work with this chunk of cpp code and translate it” aka a “definition” ( as opposed to a declaration ).
This separation into translation units is why a LOT of the cpp machinery exists just to support, modify behaviors related to it.