[comp.lang.c++] conflict

randolph@ektools.UUCP (Gary L. Randolph) (06/29/89)

OK, which is it?

Pohl's text (pg. 143):

   "If a member is transmitted to its derived class as private, this
   can be altered to public or protected, as in the following:

      class b{
      public:
         int f;
         int g;
         ...
      };

      class d : private b{
      protected:
         int b::g;   //g is converted to protected
      public:
         int b::f;   //f is converted to public
         ...
      };

In the same manner, a publicly transmitted member can be explicitly
converted to private or protected."

-------------------***--------------------

NOW, Lippman's text (pg. 318, 319):

   Examples of a class hierarchy is given that is set up as:

   class ZooAnimal    //base
   class Rodent : private ZooAnimal
       and
   class Rat : public Rodent

ZooAnimal has a public method, inform(), and a protected member,
onDisplay().

"The derived class can maintain the inherited member's access level
only.  The access level cannot be made either more or less
restrictive that the level originally specified within the base
class.  It is illegal, for example, to declare the protected
ZooAnimal class member onDisplay within a public section of Rodent
or to declare inform() within a protected section."


I am NOT looking for fault.  Writing a book on C++ cannot be an
easy task.  I may also be overlooking some detail that makes
both texts correct.  But right now, all I see is a conflict and
I need clarification.

                                    Gary   

stanl@cbnewsm.ATT.COM (stanley.b.lippman) (06/30/89)

In article <1971@ektools.UUCP>, randolph@ektools.UUCP (Gary L. Randolph) writes:
	> 
	> OK, which is it?

  **> Ira Pohl's description is correct for Release 1.*

      The behavior was changed in 2.0 to make encapsulation 
      and subtyping more secure.

      The description in the C++ Primer is correct for Release 2.0,
          and is described in section 11.3 of the Reference Manual
          cited by Bjarne in an earlier message.

	> Pohl's text (pg. 143):
	> 
	>    "If a member is transmitted to its derived class as private, this
	>    can be altered to public or protected, as in the following:
	... 
	> In the same manner, a publicly transmitted member can be explicitly
	> converted to private or protected."
	> 
	> -------------------***--------------------
	> 
	> NOW, Lippman's text (pg. 318, 319):
	> 
	> "The derived class can maintain the inherited member's access level
	> only.  The access level cannot be made either more or less
	> restrictive that the level originally specified within the base
	> class.  It is illegal, for example, to declare the protected
	> ZooAnimal class member onDisplay within a public section of Rodent
	> or to declare inform() within a protected section."