title: Why does C++ need a separate header file?
body: <p>I've never really understood why C++ needs a separate header file with the same functions as in the .cpp file. It makes creating classes and refactoring them very difficult, and it adds unnecessary files to the project. And then there is the problem with having to include header files, but having to explicitly check if it has already been included.</p>
  
  <p>C++ was ratified in 1998, so why is it designed this way? What advantages does having a separate header file have?</p>
  
  <hr>
  
  <h2>Follow up question:</h2>
  
  <p>How does the compiler find the .cpp file with the code in it, when all I include is the .h file? Does it assume that the .cpp file has the same name as the .h file, or does it actually look through all the files in the directory tree?</p>