home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_02 / saks / hides.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-14  |  511 b   |  28 lines

  1. Listing 4 - a declaration in an inner scope hides all functions with the 
  2. same name in an outer scope
  3.  
  4. #include <stdio.h>
  5.  
  6. void put(char c, FILE *stream);
  7. void put(const char *s, FILE *stream);
  8.  
  9. class File
  10.     {
  11.     FILE *f;
  12. public:
  13.     File(FILE *ff) : f(ff) { }
  14.     void put(const char *s);
  15.     };
  16.  
  17. void File::put(const char *s)
  18.     {
  19.     ::put(s, f);    // needs :: to access outer scope
  20.     }
  21.  
  22. int main()
  23.     {
  24.     File f(stdout);
  25.     f.put("hello, world\n");
  26.     return 0;
  27.     }
  28.