So I'm basically writing an inventory program that allows the user to interact with it. The code seems to work but I'm having a problem removing specific elements from the vector without using pop_back.
I know that removing entries in between the end and the start can invalidate entries but I'm not to sure as too how else I can do that whilst maintaining item validation. Should I use a map?
I get an error using erase and passing the item requested for removal, any ideas?
I know that removing entries in between the end and the start can invalidate entries but I'm not to sure as too how else I can do that whilst maintaining item validation.
Only iterators, pointers, and references to elements get invalidated. The elements themselves are not affected. If what you said were true, the erase member function would be entirely useless!
I don't understand how you see only certain errors and not others, look at the error messages I get: http://ideone.com/AL1pxt
What compiler are you using? If the version you are using was released more than 5 years ago, stop using it.
That doesn't make sense, I'm using Visual Studio 2013, I don't get any errors if I remove the erase member function. Then only one when I include it. Why do all the compilations from codepad, ideone and visual 2013 all differ?