home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- 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
- From: pl2440@meibm31.cen.uiuc.edu (Paul Jay Lucas)
- Subject: Re: Protected Derivation
- References: <4296@cvbnetPrime.COM>
- Message-ID: <Bxu2sx.Exw@news.cso.uiuc.edu>
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: University of Illinois at Urbana
- Distribution: usa
- Date: Tue, 17 Nov 1992 00:02:56 GMT
- Lines: 33
-
- In <4296@cvbnetPrime.COM> skochhar@cvbnet.prime.com (Sandeep Kochhar x4618 5-2) writes:
-
- >In the ARM, I seem to find no mention/explanation of protected derivation
- >(i.e., class Foo: protected B {...};). But I know some compilers support
- >it... Is it a recent addition to the ARM or the language? Where is
- >it explained? What does it mean (briefly)?
-
- *****> It *is* is the ARM if you read the grammar in the back; it's
- just not explained anywhere. It is explained in Lippman, 2nd
- ed., and in my book, and perhaps other places.
-
- The only difference between protected and private derivation is
- that the protected parts of the base become part of the protected
- parts of the derived class as opposed to part of the private
- parts of the derived class.
-
- One example that I can think of for using it is:
-
- class List {};
- class Dequeue : protected List {};
- class Stack : private Dequeue {};
- class Queue : private Dequeue {};
-
- Now Stack and Queue will have access to the protected parts of
- List whereas if Dequeue were privately derived, they wouldn't.
-
- Of course, you're doing all this inheritance here for *code*
- reuse and *not* because a Queue nor a Stack is-a Dequeue nor a
- List, nor is Dequeue a List.
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-