Actual quote from 15.4.1:
class BB_ival_slider : public Ival_slider, protected BBslider {
This is an uninteresting case. However, it is comforting to know that dynamic_cast does not accidentally violate the protection of private and protected base classes .
Thus, it seems that the text describing the code is correct, but for the wrong reasons - dynamic_cast does not allow accidental violation of the protection of private and protected base classes, but only because using it would be poorly formed and lead to a compiler error, and not because that using it will give a null pointer. And, of course, the code that describes the text is definitely incorrect.
Mistakes happen - perhaps this will be fixed in the fourth edition of the book .: -]
Please note that if
BB_ival_slider declares
f be
friend , the code
will behave as described in the book. Perhaps this
friend declaration was mentioned earlier in the chapter, but right now I donβt have time to read it carefully to check, anyway.)
source share