title: Manipulating global variables
body: <p>I have functions in two (linked) C++ files that both use the same variable. To me (a complete beginner) I could see two ways of handling this:</p>
  
  <ol>
  <li><p>Pass the variable from the first function to the second (they are sequential in the program), or</p></li>
  <li><p>Define the variable as a global value in a separate header file that both c++ files include at the beginning</p></li>
  </ol>
  
  <p>Whilst (1) may seem like the most obvious answer, I chose to use 2. For whatever reason.</p>
  
  <p>Anyway, the variable is now declared in the header, but if I try to assign a value to the variable at the time of declaration, I get the error "(value) already defined in main.obj".</p>
  
  <p>The header is included at the beginning of both C++ files. The variable is not declared anywhere else, but it is used.</p>
  
  <p>There must be an obvious answer to this, but I'm very new to C++. Anyone who can shed light on why I can't assign the variable a value I would be very grateful to.</p>