title: How to use extern integer in QT?
body: <p>FYI: This is not a complete program but pretty much looks like what mine does.
  From what I understand,</p>
  
  <p>I have a header file:</p>
  
  <p>header.cpp</p>
  
  <pre><code>extern int global_x;
  </code></pre>
  
  <p>mainWindow.cpp</p>
  
  <pre><code>#include "header.cpp" 
  
  int global_x=1;
  </code></pre>
  
  <p>a.cpp</p>
  
  <pre><code>#include "header.cpp"
  
  int global_x;
  cout &lt;&lt; global_x;
  </code></pre>
  
  <p>But my global_x is 0...Why????? If I take out the global_x then it won't compile.
  Can someone give an example of a simple program in QT that addresses this issue? I've looked at alot of stuff online, but mostly C uses extern and C++ not as much. thanks.</p>