Header files provide "declarations" for classes and functions. The compiler needs them, so it can: a) verify that you are passing the correct parameters and / or setting the correct data elements for the classes / structures, and b) so that it can know how to call these functions.
void do_something(int a, std::string& s);
tells the compiler that this function expects two parameters: int and a string& . This confirms that you are passing the correct parameter types (construct at the language level) and explains what the object code in the compiled library expects (two arguments β as determined by the convention call).
If this compiled library uses code from another library, you do not need to provide these headers because they have nothing to do with the code you wrote. Libraries operate at the "binary application interface" (ABI) level, rather than the "application programming interface" (API). That means they just pass pointers, etc. Not parameters with type C.
source share