I have a question about libraries. When I write a library I have 2 files: library.h
and library.cpp
.
The first one contains the prototypes of the functions and the second one contains the definitions. Well, in library.cpp
I include #include "library.h"
, so they are connected in one way, but what happens with the header? Why don't I have to write #include "library.cpp"
in the header?
When I use the library in the main file, I write #include "library.h"
, which includes the prototypes, but how does the compiler know where the definitions are?