title: Why are my C++ includes defining vars multiple times?
body: <p>I understand that pre-processor commands are an important part of header files to prevent vars and classes from being defined more than once.</p>
  
  <p>I have been running into issues with my vars being defined multiple times - even with pre-processor wrappers. Here is a sample project that is experiencing compiler errors:</p>
  
  <p>Header:</p>
  
  <pre><code>// TestInclude.h
  #ifndef TESTINCLUDE_H_
  #define TESTINCLUDE_H_
  
  int myInt;
  
  #endif /*TESTINCLUDE_H_*/
  </code></pre>
  
  <p>C++:</p>
  
  <pre><code>// TestInclude.cpp
  #include &lt;iostream&gt;
  #include "IncludeMe.h"
  #include "TestInclude.h"
  
  int main( int argc, char* args[] )
  {
      std::cin &gt;&gt; myInt;
  
      IncludeMe thisClass;
  
      std::cin &gt;&gt; myInt;
  }
  </code></pre>
  
  <p>Header:</p>
  
  <pre><code>// IncludeMe.h
  #ifndef INCLUDEME_H_
  #define INCLUDEME_H_
  
  class IncludeMe
  {
  private:
      int privateInt;
  public:
      IncludeMe();
  };
  
  #endif /*INCLUDEME_H_*/
  </code></pre>
  
  <p>C++:</p>
  
  <pre><code>// IncludeMe.cpp
  #include &lt;iostream&gt;
  #include "IncludeMe.h"
  #include "TestInclude.h"
  
  IncludeMe::IncludeMe()
  {
      std::cout &lt;&lt; "myInt: " &lt;&lt; myInt;
  }
  </code></pre>
  
  <p>Then I compile like this:</p>
  
  <p>Makefile:</p>
  
  <pre><code>all:
  g++ -g -o TestInclude TestInclude.cpp IncludeMe.cpp
  </code></pre>
  
  <p>And I get the following error:</p>
  
  <blockquote>
    <p>/tmp/ccrcNqqO.o: In function `IncludeMe':<br>
        /home/quakkels/Projects/c++/TestInclude/IncludeMe.cpp:6: multiple definition of `myInt'<br>
        /tmp/ccgo6dVT.o:/home/quakkels/Projects/c++/TestInclude/TestInclude.cpp:7: first defined here<br>
        collect2: ld returned 1 exit status<br>
        make: *** [all] Error 1</p>
  </blockquote>
  
  <p>Why am I getting this error when I'm using pre-processor conditionals in my header files?</p>