title: Merge C++ files into a single source file
body: <p>I have a c++ project with multiple source files and multiple header files.  I want to submit my project for a programming contest which requires a single source file. Is there an automated way of collapsing all the files into single .cpp file?</p>
  
  <p>For example if I had a.cpp, a.h, b.cpp, b.h etc., I want to get a main.cpp which will compile and run successfully.  If I did this manually, could I simply merge the header files and append the source files to each other?  Are there gotchas with externs, include dependencies and forward declarations?</p>