Introduction to OOP | Chapter 20: The STL : | next | previous | audio | real | text |
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 };