title: fatal error multiply defined symbols found
body: <p>I got this error but I don't understand it because "int const ITEMS" was never declared in DisplayErrorMessage.cpp like what it said in the error below..Any help.</p>
  
  <pre><code>1&gt;Main.obj : error LNK2005: "int const ITEMS" (?ITEMS@@3HB) already defined in DisplayErrorMessage.obj
  1&gt;MakeSelection.obj : error LNK2005: "int const ITEMS" (?ITEMS@@3HB) already defined in DisplayErrorMessage.obj
  1&gt;ShowMenu.obj : error LNK2005: "int const ITEMS" (?ITEMS@@3HB) already defined in DisplayErrorMessage.obj
  1&gt;c:\users\kanaan\documents\visual studio 2010\Projects\Assign2\Debug\Assign2.exe : fatal error LNK1169: one or more multiply defined symbols found
  </code></pre>
  
  <p>Here is the code:</p>
  
  <p>Header file</p>
  
  <pre><code>#ifndef _VENDINGMACHINE_H_
  #define _VENDINGMACHINE_H_
  
  #include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
    //extern int Denominations;
    extern int const ITEMS = 9;
  
    extern int Coins[5];
    extern int NumCoins[5]; //assume we have 10 coins of each denomination
  
     extern int ItemPrice[ITEMS ]; //price in cents
     extern int NumItems[ITEMS]; 
  
  
  //extern double Total_Price;
  //extern double Item_Total;
  
  class VendingMachine{
  public:
      void MakeSelection();
      int ReturnChange(int change, int Coins[], int NumCoins[]);
      void ShowMenu();
      void DisplayErrorMessage(int error);
      void PrintConfidentialInformation(int Denominations, int Items, int Coins[], 
                                                      int NumCoins[], int ItemPrice[] , int NumItems[]);
  
  private:
      int selection;
      string code;
      double Each_Item[ITEMS];       //price for each item
  };
  #endif //_VENDING_MACHINE_H_
  </code></pre>
  
  <p>The cpp files are as follows.
  MakeSelection.cpp
      #include "Vending Machine.h"</p>
  
  <pre><code>void VendingMachine::MakeSelection(){
  
  
  
     //assume we have 10 coins of each denomination
  
    double Total_Price;
  // double Item_Total;
  
    int Coins[5] = {100, 50, 20, 10, 5};
     int NumCoins[5] = {10, 10, 10, 10, 10}; 
      int ItemPrice[ITEMS] = { 75, 120, 120, 100, 150, 95, 110, 50, 120 }; //price in cents
    int NumItems[ ITEMS] = { 10, 10, 10, 10, 10, 10, 10, 10, 10 };
  
      string Product[ITEMS] = {"Water","Coke","Diet Coke","Iced Tea","Swiss Chocolate","Candy",
                                                      "Chips","Bubble Gum","Turkish Delight"};
      int b = 0;
  int a = 1;
  
  cout &lt;&lt; "Please enter the number of your choice from the menu above. " &lt;&lt; endl;
  
  do{
      cout &lt;&lt; "\nEnter the number of product OR End transaction: " &lt;&lt; endl;
      cin &gt;&gt; selection;
      cout &lt;&lt; "\nYou have selected " &lt;&lt;Product[selection] &lt;&lt; endl;
  
      if(selection &gt;= 1 &amp;&amp; selection &lt;= 9){
  
          NumItems[selection - 1] = NumItems[selection - 1] - 1;
  
          if(NumItems[selection - 1] &gt;= 0)
              Total_Price = Total_Price + ItemPrice[selection - 1];
  
          else{
              int error = 1;
              DisplayErrorMessage(error);         //Item finised
              cout &lt;&lt;selection&lt;&lt; endl;
          }
      }
      else if(selection == 10)
          cout &lt;&lt; "\nTransaction Ended" &lt;&lt; endl;
  
      else if(selection == 99){
  
          cout &lt;&lt; "Enter the code to access maintanance: " &lt;&lt;endl;
          cin &gt;&gt; code;
  
          while(code != "111"){
              int error = 2;
              DisplayErrorMessage(error);
              cin &gt;&gt; code;
          }
  
          cout &lt;&lt; endl;
          cout &lt;&lt; "\t\t\t\t\tSales Report " &lt;&lt; endl;
          cout &lt;&lt; "==================================================== " &lt;&lt; endl;
          cout &lt;&lt; endl;
          cout &lt;&lt; "Number of each product sold with Income cost: " &lt;&lt; endl;
          cout &lt;&lt; endl;
  
          do{
              if(NumItems[b] &gt;= 0){
  
                  Each_Item[b] = Each_Item[b] + ItemPrice[b];
  
                  cout &lt;&lt; NumItems[b] &lt;&lt; "" &lt;&lt; Product[b] &lt;&lt; " sold for the total cost of " &lt;&lt;(10 - NumItems [b]) * Each_Item[b]/ 100 &lt;&lt;endl;   
  
                  Total_Price = Total_Price + ((10 - NumItems[b]) * Each_Item[b]/100);
              }
              b++;
          }while(a &lt;= ITEMS);
      }
      else{ 
          int error = 3;
          DisplayErrorMessage(error);
      }
  }while(selection != 10);
  }
  </code></pre>
  
  <p>DisplayErrorMessage.cpp</p>
  
  <pre><code>#include "Vending Machine.h"
  
  void VendingMachine::DisplayErrorMessage(int error){
  
  if (error == 1){
      cout &lt;&lt; "\nSorry we are run out of item number ";
  }
  else if (error == 2){
      cout &lt;&lt; "\nInvalid selection - Please re-select your choice" &lt;&lt; endl;
  }
  else if (error == 3){
      cout &lt;&lt; "\nIncorrect Password - Please re-enter" &lt;&lt; endl;
  }
  else
      cout &lt;&lt; "\nNot enough fund" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Help pliz.</p>