Merge pull request #2317 from jwillemsen/jwi-deleteop
[ACE_TAO.git] / ACE / examples / APG / Containers / DataElement.h
blob79bfe13ce786a5f5bd32f8120bdda658b346fb20
1 /* -*- C++ -*- */
2 #if !defined(DATAELEMENT_H)
3 #define DATAELEMENT_H
5 class DataElementEx;
7 // Listing 1 code/ch05
8 // A simple data element class.
9 class DataElement
11 friend class DataElementEx;
13 public:
14 DataElement () : data_ (0) { count_++; }
16 DataElement (int data) : data_(data) { count_++; }
18 DataElement (const DataElement& e)
20 data_ = e.getData ();
21 count_++;
24 DataElement & operator= (const DataElement& e)
26 data_ = e.getData ();
27 return *this;
30 bool operator== (const DataElement& e)
31 { return this->data_ == e.data_; }
33 ~DataElement () { count_--; }
35 int getData () const { return data_; }
37 void setData (int val) { data_ = val; }
39 static int numOfActiveObjects () { return count_; }
41 private:
42 int data_;
43 static int count_;
45 // Listing 1
47 int DataElement::count_ = 0;
49 #endif /*DATAELEMENT_H*/