// File: widget1.C // // Implementation of Widget class #include #include "widget1.h" // Define a constant // const int DEFAULT_SIZE=10 ; // !!! static data members must be initialized in the following way // int Widget::count = 0 ; // Default Constructor // Widget::Widget() { size = DEFAULT_SIZE ; count++ ; serial = count ; } // Alternate Constructor // Widget::Widget(int size) { Widget::size = size ; // there are 2 size's count++ ; serial = count ; } // tell me about this widget // void Widget::display() { cout << "Widget info:\n" ; cout << " size = " << size << " serial# = " << serial << " total count = " << count << "\n" ; cout << " &size = " << &size << " &serial = " << &serial << " &count = " << &count << "\n" ; } // report about widget class // void Widget::report() { cout << "\n***Widget report:\n" ; cout << " Total number of widgets produced: " << count << "\n" ; }