// --------------------------------------------------------------------------- // retrieveItem // Takes the Item and compares it's value in the correct BinTree found after // using itemCode to hash to correct key Item* Inventory::retrieveItem(const Item *obj, char itemCode) const { BinTree *storageTree = storage[hash(itemCode)]; Item *retrieved = NULL; storageTree->retrieve(obj, retrieved); return retrieved; }
//------------------------------------------------ setCustomer() void Borrow::setCustomer(istream& in, BinTree& cust) { int customerID = 0; in >> customerID; Customer target(customerID); // empty instance with only id Generic* customerInStore = NULL; cust.retrieve(target, customerInStore); // pointer is now modified to point to the customer in our store if(customerInStore != NULL) { // if found // down-cast and store reference customer = dynamic_cast<Customer*>(customerInStore); } else { customer = NULL; } // target goes out of scope and gets destroyed }