home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_11 / 8n11085a < prev    next >
Text File  |  1990-09-18  |  636b  |  26 lines

  1.  
  2. # include <stdio.h>
  3. typedef int Truth;
  4. class File { // Implementation layered on FILE
  5. public:
  6.     File( char *name = "", char *mode = "r") { /* implemented as before */ }
  7.  
  8.     ~File()           { if( fp) fclose( fp); }
  9.  
  10.     Truth isok()      { return state; }
  11.  
  12.     Truth iseof()     { return feof( fp); }
  13. protected:          // only visible to derived class member functions
  14.     int get()         { return getc( fp); }
  15.  
  16.     void unget(int c) { (void)ungetc( c, fp); }
  17.  
  18.     int peek()        { int c = get(); unget(c); return c; }
  19.  
  20.     void put( int c)  { putc( c, fp); }
  21. private:
  22.     FILE *fp;
  23.     int state;
  24. };
  25.  
  26.