title: Compiling multiple .cpp and .h files using g++. Am I doing it right?
body: <p>Lets say I have these files:
  <code>main.cpp</code>, <code>ClassA.cpp</code>, <code>ClassA.h</code>, <code>ClassB.cpp</code>, <code>ClassB.h</code></p>
  
  <ul>
  <li>The main has <code>#include "ClassA.h"</code> and <code>#include "ClassB.h"</code> and each <code>.cpp</code> file includes its respective <code>.h</code> file.  Is this correct?</li>
  </ul>
  
  <p>Now I am compiling using <code>g++ *.cpp</code> after which I get an executable <code>a.exe</code> (Windows)</p>
  
  <ul>
  <li>And my question is that is this the right way? And lets say if I only make changes in one file (cpp or h)will this command also recompile the unchanged files(because I see no new files in the folder except a.exe)? Please explain. Also how do I prevent that?</li>
  </ul>
  
  <p>P.S I am not familiar with make and do not want to use that either so please do not refer to that in the answers and I read <a href="https://stackoverflow.com/questions/3202136/using-g-to-compile-multiple-cpp-and-h-files">Using G++ to compile multiple .cpp and .h files</a> but I need more explanation regarding my questions.</p>