title: How do C++ header files work?
body: <p>When I include some function from a header file in a C++ program, does the entire header file code get copied to the final executable or only the machine code for the specific function is generated. For example, if I call <code>std::sort</code> from the <code>&lt;algorithm&gt;</code> header in C++, is the machine code generated only for the sort() function or for the entire <code>&lt;algorithm&gt;</code> header file. </p>
  
  <p>I think that a similar question exists somewhere on Stack Overflow, but I have tried my best to find it (I glanced over it once, but lost the link). If you can point me to that, it would be wonderful. </p>