home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C14 / Privinh.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  534 b   |  27 lines

  1. //: C14:Privinh.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Private inheritance
  7.  
  8. class Base1 {
  9. public:
  10.   char f() const { return 'a'; }
  11.   int g() const { return 2; }
  12.   float h() const { return 3.0; }
  13. };
  14.  
  15. class Derived : Base1 { // Private inheritance
  16. public:
  17.   Base1::f; // Name publicizes member
  18.   Base1::h;
  19. };
  20.  
  21. int main() {
  22.   Derived d;
  23.   d.f();
  24.   d.h();
  25. //! d.g(); // Error -- private function
  26. } ///:~
  27.