1 #ifndef DEFAULTONLY_H 2 #define DEFAULTONLY_H 3 4 #include <cassert> 5 6 class DefaultOnly 7 { 8 int data_; 9 10 DefaultOnly(const DefaultOnly&); 11 DefaultOnly& operator=(const DefaultOnly&); 12 public: 13 static int count; 14 15 DefaultOnly() : data_(-1) {++count;} 16 ~DefaultOnly() {data_ = 0; --count;} 17 18 friend bool operator==(const DefaultOnly& x, const DefaultOnly& y) 19 {return x.data_ == y.data_;} 20 friend bool operator< (const DefaultOnly& x, const DefaultOnly& y) 21 {return x.data_ < y.data_;} 22 }; 23 24 int DefaultOnly::count = 0; 25 26 #endif // DEFAULTONLY_H 27