Compiler compiles only cpp files . Cpp and h file should be in one file, but the need to have them separate caused for #include directive, so you simply put them to file you need to compile (literaly). The reason to separatet them is, that other projects may need to use your library, but would like to do so without compiling your library, so they just put your h. files to their cpp files and compile them, and on runtime your library internal routine is run. When you will code modules/libraries/projects, whatever is the termine, you will understand also obstacles this design brings.
Help me understand .cpp vs .h in C++
20 replies to this topic