code_junkie

Private/protected inheritance

Nov 13th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. class Base;
  2. class Derived1 : private Base;
  3. class Derived2 : protected Base;
  4.  
  5. class Engine {
  6. public:
  7. Engine(int numCylinders);
  8. void start(); // Starts this Engine
  9. };
  10.  
  11. class Car {
  12. public:
  13. Car() : e_(8) { } // Initializes this Car with 8 cylinders
  14. void start() { e_.start(); } // Start this Car by starting its Engine
  15. private:
  16. Engine e_; // Car has-a Engine
  17. };
  18.  
  19. class Car : private Engine { // Car has-a Engine
  20. public:
  21. Car() : Engine(8) { } // Initializes this Car with 8 cylinders
  22. using Engine::start; // Start this Car by starting its Engine
  23. };
  24.  
  25. struct noncopyable {
  26. private:
  27. noncopyable(noncopyable const&);
  28. noncopyable & operator=(noncopyable const&);
  29. };
  30.  
  31. class my_noncopyable_type : noncopyable {
  32. // ...
  33. };
  34.  
  35. template <typename T>
  36. class CBigArray : public IArray, private CLnkList {
  37. // ...
Add Comment
Please, Sign In to add comment