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

Example Program-Inventory System

A business, WorldWideWidgetWorks, manufactures widgets.

class  Widget {
public:
		// constructors
	Widget () : id_number (0) { }
	Widget (int a) : id(a) { }
		// operations
	int id () { return id_number; }
	void operator =  (Widget & rhs) 
		{ id_number = rhs.id_number; }
	bool operator == (Widget & rhs) 
		{ id_number == rhs.id_number; }
	bool operator <  (Widget & rhs) 
		{ id_number < rhs.id_number; }
protected:
	int id_number;	// widget identification number
};
Intro OOP, Chapter 16, Slide 11