title: Accessing multiple instances of a class in C++
body: <p>I am creating a menu for a restaurant that can have 5 dishes of each category. So far I have created a class for meat dishes and I'm able to add up to 5 dishes, each with a unique identifier. What I am having trouble with is accessing the objects after they have been created. 
  (There will be multiple categories hence why there is a switch statement with only one case so far).</p>
  
  <p>For example, how would I implement a way to change the description of the second dish?</p>
  
  <p>Here is my code so far:</p>
  
  <p>meat.h</p>
  
  <pre><code>    class Meat{
  private:
      int meatNumber;
      std::string meatCategory;
      std::string meatDescription[MAX_ITEMS];
      double meatPrice[MAX_ITEMS];
  
      public:
          Meat();
          //setter functions
          int setMeatNumber();
          std::string setMeatDescription();
          double setMeatPrice();
  
          //getter functions
          int getMeatNumber();
          std::string getMeatCategory();
          std::string getMeatDescription(int i);
          double getMeatPrice(int i);
      };
  </code></pre>
  
  <p>meat.cpp</p>
  
  <pre><code>#include "Meat.h"
  
  //constructor
      Meat::Meat() {
      meatNumber = 0;
      meatCategory = "Meat";
      meatDescription[MAX_ITEMS] = "No description written.";
      meatPrice[MAX_ITEMS] = 0.0;
  }
  
  //setter functions
  int Meat::setMeatNumber(){
      static int counter = 1;
      meatNumber = counter++;
  }
  
      std::string Meat::setMeatDescription(){
          int i = 0;
          std::cout &lt;&lt; "Please enter a short description: " &lt;&lt; std::endl;
          std::cin &gt;&gt; meatDescription[i];
          return meatDescription[i];
      }
  
      double Meat::setMeatPrice(){
          int i = 0;
          std::cout &lt;&lt; "Please set the price in a 00.00 format: " &lt;&lt; std::endl;
          std::cout &lt;&lt; "£";
          while(!(std::cin &gt;&gt; meatPrice[i])){
             std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
             std::cout &lt;&lt; "Error. Please enter a number: ";
          }
          return meatPrice[i];
      }
  
      //getter functions
      int Meat::getMeatNumber() { return meatNumber; }
      std::string Meat::getMeatCategory() { return meatCategory; }
      std::string Meat::getMeatDescription(int i) {return meatDescription[i]; }
      double Meat::getMeatPrice(int i) { return meatPrice[i]; }
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>    #include &lt;iostream&gt;
  #include "Meat.h"
  
  
  
  int main() {
  int choice;
  
      std::cout &lt;&lt; "Menu Creation Terminal\n\n" &lt;&lt; std::endl;
      std::cout &lt;&lt; "\t Welcome\nto Wrapid™ Restaurants\n\n" &lt;&lt; std::endl;
      std::cout &lt;&lt; "1. Add Meat Dish\n2. Add Fish Dish\n3. Add Vegetarian Dish\n4. Add Drink\n"
                   "5. Edit Current Menu\n6. Quit\n\n" &lt;&lt; std::endl;
      std::cout &lt;&lt; "Please select an option: ";
      std::cin &gt;&gt; choice;
  
      switch (choice) {
          case 1:
              {
              int option = true;
              int count = 0, i;
              Meat meatDish;
              std::cout &lt;&lt; "Meat Dishes" &lt;&lt; std::endl;
              while (true) {
                  meatDish.setMeatNumber();
                  meatDish.setMeatDescription();
                  meatDish.setMeatPrice();
  
                  //functions to add details to dish
                  std::cout &lt;&lt; "You have added the following dish: " &lt;&lt; std::endl;
                  std::cout &lt;&lt; "Item number: \n" &lt;&lt; meatDish.getMeatNumber() &lt;&lt; std::endl;
                  std::cout &lt;&lt; "Item Category: \n " &lt;&lt; meatDish.getMeatCategory() &lt;&lt; std::endl;
                  std::cout &lt;&lt; "Item Description: \n" &lt;&lt; meatDish.getMeatDescription(i) &lt;&lt; std::endl;
                  std::cout &lt;&lt; "Item Price: \n £" &lt;&lt; meatDish.getMeatPrice(i) &lt;&lt; std::endl;
  
                  std::cout &lt;&lt; "Would you like to add another item? Press 1 for yes or 2 for no: " &lt;&lt; std::endl;
                  std::cin &gt;&gt; option;
                  count += 1;
                  if (count == 5) {
                      std::cout &lt;&lt; "Error. Exceeded maximum items.";
                      break;
                  } //breaks out of loop if more than 5 items
                  if (option == 2) { break; } //breaks out of loop when user is finished adding items
              }//while loop to contain menu
          }//brace for scope of case 1
  }
  
  
  return 0;
  </code></pre>
  
  <p>}</p>