home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16400 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.8 KB  |  46 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!meibm31.cen.uiuc.edu!pl2440
  3. From: pl2440@meibm31.cen.uiuc.edu (Paul Jay Lucas)
  4. Subject: Re: Protected Derivation
  5. References: <4296@cvbnetPrime.COM>
  6. Message-ID: <Bxu2sx.Exw@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: University of Illinois at Urbana
  9. Distribution: usa
  10. Date: Tue, 17 Nov 1992 00:02:56 GMT
  11. Lines: 33
  12.  
  13. In <4296@cvbnetPrime.COM> skochhar@cvbnet.prime.com (Sandeep Kochhar x4618 5-2) writes:
  14.  
  15. >In the ARM, I seem to find no mention/explanation of protected derivation
  16. >(i.e., class Foo: protected B {...};).  But I know some compilers support
  17. >it... Is it a recent addition to the ARM or the language?  Where is
  18. >it explained?  What does it mean (briefly)?
  19.  
  20. *****>    It *is* is the ARM if you read the grammar in the back; it's
  21.     just not explained anywhere.  It is explained in Lippman, 2nd
  22.     ed., and in my book, and perhaps other places.
  23.  
  24.     The only difference between protected and private derivation is
  25.     that the protected parts of the base become part of the protected
  26.     parts of the derived class as opposed to part of the private
  27.     parts of the derived class.
  28.  
  29.     One example that I can think of for using it is:
  30.  
  31.         class List {};
  32.         class Dequeue : protected List {};
  33.         class Stack : private Dequeue {};
  34.         class Queue : private Dequeue {};
  35.     
  36.     Now Stack and Queue will have access to the protected parts of
  37.     List whereas if Dequeue were privately derived, they wouldn't.
  38.  
  39.     Of course, you're doing all this inheritance here for *code*
  40.     reuse and *not* because a Queue nor a Stack is-a Dequeue nor a
  41.     List, nor is Dequeue a List.
  42. -- 
  43.     - Paul J. Lucas                University of Illinois    
  44.       AT&T Bell Laboratories        at Urbana-Champaign
  45.       Naperville, IL            pjl@cs.uiuc.edu
  46.