home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK4 / SAMPLES / CPPTUTOR / SAVINGS.H$ / SAVINGS
Encoding:
Text File  |  1991-12-11  |  763 b   |  34 lines

  1. // SAVINGS.H
  2.  
  3. // This is an example class from Chapter 6 of the C++ Tutorial. This
  4. //     class demonstrates static data members and static member
  5. //     functions.
  6.  
  7. #if !defined( _SAVINGS_H_ )
  8.  
  9. #define _SAVINGS_H_
  10.  
  11. #include <iostream.h>
  12.  
  13. class SavingsAccount
  14. {
  15. public:
  16.     SavingsAccount( const char *nm, float tl );
  17.     void display() const;
  18.     void earnInterest() { total += currentRate * total; }
  19.     static void setInterest( float newValue )
  20.          { currentRate = newValue; }   // Static member function
  21. private:
  22.     char name[30];
  23.     float total;
  24.     static float currentRate;          // Static data member
  25. };
  26.  
  27. inline void SavingsAccount::display() const
  28. {
  29.     cout << name << ' ' << total;
  30. }
  31.  
  32. #endif  // _SAVINGS_H_
  33.  
  34.