Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

math_proof Group Title

vector of class items in a inventory program help

  • one year ago
  • one year ago

  • This Question is Closed
  1. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Assuming that you're using vector because you're dynamically creating items, the creation of each item would return a pointer to the created item. So your vector would be holding item pointers.

    • one year ago
  2. math_proof Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    here is what i have so far: http://liveworkspace.org/code/5fc3bc736d1982c949f5cc6f8e088a02 so what i want to do is after inserting some of the products into the vector then in 1. item sale i want to type a specific ID corresponding to some product which then it would use i guess iterator to find that product and print it

    • one year ago
  3. eSpeX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    What about making your "Item" class have a protected bool variable, "on-sale", so when your items are created they will inherit that property. Then you can set the bool to true if it's on sale and use a method in the class to calculate a sale price and print it when called.

    • one year ago
  4. math_proof Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    somehow it looks complicated to use another methods etc... isn't there another option

    • one year ago
  5. math_proof Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    will then the iterator work or what?, why isn't that iterator work in my example

    • one year ago
  6. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Does this code run? I'd be surprised it Item::print() doesn't require std::cout and I think that Item::actual_qunatity is a typo ("na" transposed). Can Inventory be decoupled from items? Inventory does include all items, but is really only concerned with the count of items and maybe reorder points.

    • one year ago
  7. math_proof Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    it doesn't compile you can see it on the link i gave that it gives an error in inventory::sale error: no matching function for call to 'find(std::vector<Item>::iterator, std::vector<Item>::iterator, int&)'. I just want to do a inventory program but im really lost, it should update quantity sold in sale and etc..

    • one year ago
  8. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    First, stop and take a breath. Now go back and give your class designs another look. You tried using the current designs to create a system, and now you have a better perspective of what's needed. FWIW, I treat my classes as separate projects. I write them and write a test program to make sure they're okay, and then they can be copied into an applications project.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.