I started the OOP chapter yesterday, and I get most of what is happening. However, there's one thing that's not really explained that I really do not get.
What I see them do is create 3 files, a header.h, a implementation.cpp and a main file.
//main CPP file
#include "headerFile.h"
int main ()
{
// code
}
Now for my question, how does the main file reach the implementation? There is no include towards it, It includes the header file, but the header does not include the cpp file. I tested it, and executed it, and it works, but it baffles me how?
I can only assume that the implementation file is linked by the compiler to the header file somehow behind the scene, as there definitely is no code linking them.
that is the task of the linker.. your code gets compiled... and it compiles main and the header and it compiles the implementation and the header file...
The linker 'sees' you are using the definitions defined in the header in your main loop... and linkes them to the implementation in the in the implementation cpp file...