// File: widget2.C // // Implementation of Widget v2.0 #include #include "widget2.h" // !!! static data members must be initialized in the following way // int Widget::count = 0 ; int Widget::sequence = 0 ; // Constructor with default value for size // Widget::Widget(int size /* = DEFAULT_SIZE */ ) { Widget::size = size ; // there are 2 size's count++ ; sequence++ ; serial = sequence ; } // Destructor! // Widget::~Widget() { count-- ; } // tell me about this widget // void Widget::display() { cout << "Widget info:\n" ; cout << " size = " << size << " serial# = " << serial << " count = " << count << " sequence = " << sequence << "\n" ; cout << " &size = " << &size << " &serial = " << &serial << "\n" ; } // report about widget class // void Widget::report() { cout << "\n***Widget report:\n" ; cout << " Total number of widgets produced: " << sequence << "\n" ; cout << " Total number of widgets in existence: " << count << "\n" ; }