Introduction to OOP: Chapter 16 : A Case Study : The STL [next] [previous] [audio] [real] [text]

Item Arrives on Order

void inventory::order (int wid)
	// process an order for a widget with given id number
{	 cout << "Received order for widget type " << wid << endl;

	list<Widget>::iterator we_have = 
		find_if(on_hand.begin(), on_hand.end(), WidgetTester(wid));

	if (we_have != on_hand.end()) {
		cout << "Ship " << *wehave << endl;
		on_hand.erase(we_have);
		}
	else {
		cout << "Back order widget of type "  << wid  << endl;
		on_order.push_front(wid);
		}
}
Intro OOP, Chapter 16, Slide 14