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

  1. //: C05:Private.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. // Setting the boundary
  7.  
  8. struct B {
  9. private:
  10.   char j;
  11.   float f;
  12. public:
  13.   int i;
  14.   void func();
  15. };
  16.  
  17. void B::func() {
  18.   i = 0;
  19.   j = '0';
  20.   f = 0.0;
  21. };
  22.  
  23. int main() {
  24.   B b;
  25.   b.i = 1;    // OK, public
  26. //!  b.j = '1';  // Illegal, private
  27. //!  b.f = 1.0;  // Illegal, private
  28. } ///:~
  29.