home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 4-3.C < prev    next >
C/C++ Source or Header  |  1991-12-04  |  624b  |  41 lines

  1. /* Copyright (c) 1992 by AT&T Bell Laboratories. */
  2. /* Advanced C++ Programming Styles and Idioms */
  3. /* James O. Coplien */
  4. /* All rights reserved. */
  5.  
  6. #include <iostream.h>
  7.  
  8. void f(int j) { cout << "::f(int)" << endl; }
  9.  
  10. class A {
  11. public:
  12.     void f(int) { cout << "A::f(int)" << endl; }
  13. };
  14.  
  15. class B: public A {
  16. public:
  17.     void f(double) { cout << "B::f(double)" << endl; }
  18.     void g(int);
  19. };
  20.  
  21. void B::g(int k) {
  22.     f(k);
  23.     A::f(k);
  24.     this->A::f(k);
  25.     ::f(k);
  26.     f(6);
  27.     ::f(5);
  28. }
  29.  
  30. int main() {
  31.     A *a = new A;
  32.     B *b = new B;
  33.  
  34.     a->f(1);
  35.     a->f(3.0);
  36.     b->f(2);
  37.     b->f(2.0);
  38.     b->A::f(7.0);
  39.     b->g(10);
  40. }
  41.