title: How to use function variables in the main?
body: <p>Hey i have a function that contains the STL container vector.  </p>
  
  <pre><code>void displayInventory()
  {
      vector&lt;string&gt; inventory;
      cout&lt;&lt; "You have " &lt;&lt; inventory.size() &lt;&lt; " items.\n";
      cout&lt;&lt; "\nYouritems:\n";
      for (int i= 0; i&lt; inventory.size(); ++i)
      cout&lt;&lt; inventory[i] &lt;&lt; endl;
  }
  </code></pre>
  
  <p>And i wanna use the actual vector in another method play game.</p>
  
  <pre><code>int playGame()
  {
      inventory.push_back("sword"); //This is an error. Expression must have class.
  }
  </code></pre>
  
  <p>Can anyone help me do this without having to globalize the vector declaration ?</p>