home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / samples.z / static.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-30  |  808 b   |  34 lines

  1. // "Static Members" -- STATIC.HPP
  2. //
  3. // This program that illustrates the use of
  4. //   static data and static member functions.
  5.  
  6. #include <iostream.h>
  7.  
  8. class myComplex
  9. {
  10.   public:
  11.     myComplex();        // default constructor
  12.     myComplex( myComplex& C);    // copy constructor
  13.     ~myComplex();        // destructor
  14.  
  15.     static int getCount()    // static member function
  16.       { return m_nCount; }    // that returns the number of
  17.                 // instances of myComplex class
  18.  
  19.     void setReal(double fReal) // other member functions
  20.       { m_fReal = fReal; }    
  21.     void setImag(double fImag)
  22.       { m_fImag = fImag; }
  23.  
  24.     void show();
  25.  
  26.     static int m_nCount;    // the static data member
  27.  
  28.   protected:
  29.     double m_fReal;        // hidden member data
  30.     double m_fImag;           // (class use only)
  31. };
  32.  
  33.  
  34.