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

  1. //: C14:Car.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 composition
  7.  
  8. class Engine {
  9. public:
  10.   void start() const {}
  11.   void rev() const {}
  12.   void stop() const {}
  13. };
  14.  
  15. class Wheel {
  16. public:
  17.   void inflate(int psi) const {}
  18. };
  19.  
  20. class Window {
  21. public:
  22.   void rollup() const {}
  23.   void rolldown() const {}
  24. };
  25.  
  26. class Door {
  27. public:
  28.   Window window;
  29.   void open() const {}
  30.   void close() const {}
  31. };
  32.  
  33. class Car {
  34. public:
  35.   Engine engine;
  36.   Wheel wheel[4];
  37.   Door left, right; // 2-door
  38. };
  39.  
  40. int main() {
  41.   Car car;
  42.   car.left.window.rollup();
  43.   car.wheel[0].inflate(72);
  44. } ///:~
  45.