home *** CD-ROM | disk | FTP | other *** search
- //: C05:Public.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Public is just like C's struct
-
- struct A {
- int i;
- char j;
- float f;
- void func();
- };
-
- void A::func() {}
-
- struct B {
- public:
- int i;
- char j;
- float f;
- void func();
- };
-
- void B::func() {}
-
- int main() {
- A a; B b;
- a.i = b.i = 1;
- a.j = b.j = 'c';
- a.f = b.f = 3.14159;
- a.func();
- b.func();
- } ///:~
-