title: Importance of declaring variables and functions in header file
body: <p>I declare all variables and functions in .h file and has become my habit to do that (I'm programming with cocos2dx)</p>
  
  <p>And I read that you should try to include the least in .h file and the most in .cpp file.</p>
  
  <p>Because I declare all variables and functions in .h file, If I need to use another class from another file, then I need to include that class in the .h file to declare that class as a variable.</p>
  
  <p>So I want to know the importance of declaring variables in .h file and .cpp file. I want to know which way is most standard as well. </p>
  
  <p>If there is no difference, then why people would declare variables and functions in private file because declaring a function in .h file requires you to write it again in .cpp file.</p>
  
  <p>ie)</p>
  
  <p><code>.h file</code>:</p>
  
  <pre><code>class classA {
  private:
      void function();
  };
  </code></pre>
  
  <p><code>.cpp file</code>:</p>
  
  <pre><code>void classA::function() {
      ...do something...
  }
  </code></pre>
  
  <p>What is the importance of declaring variables and functions in header files?</p>