title: Creating shopping cart
body: <p>for my class were creating a mini store, and I have the three main functions that work, main.cpp, items.cpp, items.h. but the shoppingcart.cpp and the shoppinfcart.h keeps giving me issues, because I'm trying to pass the parameters from main.cpp, for example (sc1.add(&amp;a) to the functions in shoppingcart.h and shopping cart.cpp.</p>
  <p>I have attached copy of my code. any help will be appreciated.</p>
  <p><strong>Item.h</strong></p>
  <pre><code>#ifndef Items_hpp
  #define Items_hpp
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  class Items {
    private: 
    
    string ItemName;
    float ItemPrice;
    int ItemQuant;
    
    public:
    
    Items();
    
    Items(string in, float ip, int iq);
    
    void Name(string in);
    string entername();
    void CalcPrice( float ip);
    float enterprice();
    void CalcQuant(int iq);
    int enterquant();
    
  };
  #endif
  </code></pre>
  <p><strong>Items.cpp</strong></p>
  <pre><code>#include &quot;Items.h&quot;
  
  Items::Items()
  :ItemName(&quot;&quot;)
  ,ItemPrice(0)
  ,ItemQuant(0)
  {
  }
  
  
  Items::Items(string in, float ip, int iq)
  :ItemName(in)
  ,ItemPrice(ip)
  ,ItemQuant(iq)
  {
  }
  
  void Items:: CalcPrice(float ip)
  {
    ItemPrice = ip;
  }
  
  void Items::CalcQuant(int iq)
  {
    ItemQuant = iq;
  }
  
  void Items:: Name(std::string in)
  {
    ItemName = in;
  }
  
  float Items:: enterprice()
  {
    return ItemPrice;
  }
  
  int Items:: enterquant()
  {
    return ItemQuant;
  }
  
  string Items:: entername()
  {
    return ItemName;
  }
  </code></pre>
  <p>a snippet of the code for adding items to vector
  <strong>ShoppingCart.cpp</strong></p>
  <pre><code>#include &quot;ShoppingCart.h&quot; 
  #include &lt;vector&gt;
  
  void ShoppingCart ::add(&amp;its)
  {
  shopitems.push_back(&amp;its);
  }
  </code></pre>
  <p><strong>ShoppingCart.h</strong></p>
  <pre><code>#ifndef ShoppingCart_hpp
  #define ShoppingCart_hpp
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &quot;Items.h&quot;
  using namespace std;
  
  
  class ShoppingCart
  {
    private:
    vector &lt;const char its&gt; shopitems;
    string cname; //customers name
    string cdate; // todays date
  
    public:
    ShoppingCart();
    ShoppingCart(string cname);
    void add( char *its);
  };
  
  
  #endif
  </code></pre>
  <p>an example of main
  <strong>main.cpp</strong></p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &quot;Items.h&quot; 
  #include &quot;ShoppingCart.h&quot;
  using namespace std;
  
  int main() {
    char choice;
    int itemsbuy;
    float org = .75;
    float appl = .25;
    float pear = 1.00;
    float bana = .85;
    float grape = 6.00;
    float oatmlk = 5.00;
    float almmlk = 6.00;
    float cashmlk= 5.00;
    float soymlk = 4.00;
    float cocomlk = 3.00;
    float twopermlk = 3.00;
    float vitdmlk = 4.00;
    float fatmlk = 4.00;
    float goatmlk = 6.00;
    float rasinbran = 4.00;
    float granola = 5.00;
    float honeybunches = 6.00;
    float twix = 4.00;
    float honey = 5.00;
    float yogurt = 1.50;
    float cashyog = 2.00;
    float eggs = 1.80;
    float vegeggs = 3.00;
    float cheese = 2.00;
    float alcheese = 3.00;
    int itemop;
    int itemno;
    int productcounter = 0;
    int productsum= 0;//might need.
    
    
  
    cout &lt;&lt; &quot;Welcome to J&amp;S Breakfast Grocery store!&quot;&lt;&lt;endl;
    cout &lt;&lt; &quot;--------------------------------------&quot;&lt;&lt;endl;
    cout &lt;&lt; &quot;How many items will you be purchasing today?&quot;&lt;&lt;endl;
    cout &lt;&lt; endl;
    cin &gt;&gt; itemsbuy;
    ShoppingCart sc1;                        //**intializing &quot;shoppingcart.h&quot;**//
    for (int i = 0; i &lt; itemsbuy; i++) {
      cout &lt;&lt; &quot;Menu:&quot;&lt;&lt;endl;
      cout &lt;&lt; &quot;---------------------------&quot;&lt;&lt;endl;
      cout &lt;&lt; &quot;A. Fruits&quot;&lt;&lt;endl;
      cout &lt;&lt; &quot;B. Non-Diary&quot;&lt;&lt;endl;
      cout &lt;&lt; &quot;C. Diary&quot; &lt;&lt;endl;
      cout &lt;&lt; &quot;D. Cereal&quot; &lt;&lt;endl;
      cout &lt;&lt; &quot;E. Other&quot;&lt;&lt;endl;
      cout &lt;&lt; &quot;Please select your type of items to add to cart&quot;&lt;&lt;endl;
      cin &gt;&gt; choice;
      cout &lt;&lt; endl;
      switch (choice) {
        case 'A':
        case 'a':
          cout &lt;&lt; &quot;Menu:&quot; &lt;&lt;endl;
          cout &lt;&lt; &quot;---------------------------&quot;&lt;&lt;endl;
          cout &lt;&lt; &quot;1.Oranges -$ &quot;&lt;&lt; org&lt;&lt;endl;
          cout &lt;&lt; &quot;2.Apples -$ &quot;&lt;&lt; appl &lt;&lt; endl;
          cout &lt;&lt; &quot;3.Pears - $&quot;&lt;&lt;pear&lt;&lt;endl;
          cout &lt;&lt; &quot;4.Bananas - $&quot; &lt;&lt; bana &lt;&lt; endl;
          cout &lt;&lt; &quot;5.Grapes - $&quot; &lt;&lt; grape &lt;&lt; endl;
          cout &lt;&lt; endl;
          cout &lt;&lt; &quot;Chooose option&quot;&lt;&lt;endl;
          cin &gt;&gt; itemop;
          cout &lt;&lt; &quot;How Many?&quot;&lt;&lt;endl;
          cin &gt;&gt; itemno;
          if (itemno &gt; itemsbuy) {
            cout &lt;&lt; &quot;Error, cannot add more than youre planning to buy. Please start over.&quot;&lt;&lt;endl;
            break;
          }
          else {
          if (itemop ==1) {
            Items a(&quot;Oranges&quot; , org, itemno);
            productcounter++;
            sc1.add(&amp;a);                       //**trying to pass parameter here**//
            if (productcounter == itemsbuy) {
             cout&lt;&lt; &quot;Error. You are attempting to buy more than you planned. Please Start over. Thank you.&quot;&lt;&lt;endl;
            }
          }
          
  </code></pre>