vector erase iterator outside of range

 
customer->GetInventory().erase(customer->GetInventory().begin()+choice);


"customer" is a class.
"Inventory" is a class.
"GetInventory()" returns a vector<Inventory>.


It would be helpful if someone could explain to me why it returns a "vector erase iterator outside of range" error. Thank you in advance. :)
Last edited on
"GetInventory()" returns a vector<Inventory>.
Really? A copy, not a reference?

In that case this and that calls are returning copies of original. Different copies.
1
2
customer->GetInventory().erase(customer->GetInventory().begin()+choice);
//                    ↑ This                     That ↑ 
Return vector by reference.
Ohh ok. Thank you :D
Topic archived. No new replies allowed.