title: Vending Machine c++
body: <p>I am currently working on a vending machine program. However, I am not able to figure out how to ask the user for input and also print out the options and prices. This is a part of my code, my question is : How can i ask the user for an input in main() and get the options from the Base subclass.</p>
  
  <p>Thank you in advance.</p>
  
  <pre><code>class Product
  {
    protected:
      string product_description;
      int itemCost = 0;
  
    public:
      virtual void consume(void)
      {
      }
  
      virtual int cost(void) { return this-&gt;itemCost; }
      virtual string description(void) { return product_description; }
      virtual Product* ReturnHighestCostItem(void)
      {
        return this;
      }
      virtual void RemoveHighestCostItem(void)
      {
        return;
      }
  };
  
  class Base : public Product
  {
     public:
       Base(int option)
       {
         if (option == 1)
         {
           this-&gt;product_description = "Plain";
           this-&gt;itemCost = 100;
         }
         else if (option == 2)
         {
           this-&gt;product_description = "Spicy";
           this-&gt;itemCost = 150;
         }
         else if (option == 4)
         {
           this-&gt;product_description = "Chocolate";
           this-&gt;itemCost = 200;
         }
         else if (option == 8)
         {
           this-&gt;product_description = "Coconut";
           this-&gt;itemCost = 200;
         }
         else if (option == 16)
         {
           this-&gt;product_description = "Fruity";
           this-&gt;itemCost = 200;
         }
      }
  };
  
  int main()
  {
     Product obj; 
     cout &lt;&lt; "The Available descriptions are:" &lt;&lt; obj.description()&lt;&lt; endl;
     return 0;
  }
  </code></pre>