Q&A

Q

: class D2 inherits from class D1, which inherits from class Base. To keep D2 from accessing the public members in Base, what access specifier would you use and where would you use it?

A

: the relationship between D1 and Base should be private to restrict class D2 from accessing the public members of Base.

Q: why don't use protect?
A: protect lets the derived class access all public and protected members in Base.

classes inherit private by default, if the derived had been a struct, that inheritance would've been public.