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

  1. //: C05:Public.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. // Public is just like C's struct
  7.  
  8. struct A {
  9.   int i;
  10.   char j;
  11.   float f;
  12.   void func();
  13. };
  14.  
  15. void A::func() {}
  16.  
  17. struct B {
  18. public:
  19.   int i;
  20.   char j;
  21.   float f;
  22.   void func();
  23. };
  24.  
  25. void B::func() {}  
  26.  
  27. int main() {
  28.   A a; B b;
  29.   a.i = b.i = 1;
  30.   a.j = b.j = 'c';
  31.   a.f = b.f = 3.14159;
  32.   a.func();
  33.   b.func();
  34. } ///:~
  35.