From what I have read and understood, the #include directive in a source file, like for ex: main.cpp, just copies the content of the included file to the .cpp. So, when I include a header file, for ex: yum.h, all the statements in yum.h are copied into main.cpp.
The header file will just have declarations and the actual definition will be in a corresponding .cpp file, like yum.cpp.
So, while compiling main.cpp, how will the compiler know to look for the definition of any function mentioned in yum.h in yum.cpp? How will the compiler know to complie the yum.cpp file too, as there is no reference to it in either main.cpp file or yum.h.
Also, why should yum.h be included in yum.cpp?
This may sound like a stupid question. I am a beginner to OOP and C++, and am just trying to understand what is happening.