It's good to be able to use someting, it's better to understand how it works.
www.goanation.net
It's good to be able to use someting, it's better to understand how it works.
www.goanation.net
Stephan van Hulst wrote:Yes, a Hippo does have a name.
You are saying Hippo has a name. If so , Where does the name come from ? From its superclass ,right? If so , why does it say that private members are not inherited?
Swastik
Crystal Zeng wrote:A class is a blueprint for its object.An object is designed based on its members. If Hippo has no members called name, why Hippo's name data exist? It seems strange.
Swastik
Imagine that the circles on the page 251 digram are solid. Imagine that they have holes in which the public getName() member is allowed to go through, but the private name member isn't allowed through.Hippo has to depend on the Animal part of himself to keep the name instance variable....
HFJ, page 251 wrote:... if Animal has instance variables that Hippo doesn't inherit ... Hippo still depends on the Animal methods that use those variables.
Campbell Ritchie wrote:How can Hippo have the name if it can't touch it?
Hippo extends Animal so we can say that Hippo IS AN Animal. So an Hippo object has all the Animal attributes and methods (even those private). I have said an Hippo OBJECT. But Hippo class obviously does not have those attributes and methods (not even the public as they are in Animal), and that's we say that they are not inherited.
Crystal Zeng wrote:
Campbell Ritchie wrote:How can Hippo have the name if it can't touch it?
You have a big box, and you can't open it by hand directly , you need a key to open it. In this situation, you say to people ,"No, I don't have a box."
Swastik
I think it is more accurate to say that Hippo has private members from its superclass,but has no direct access to them
Consider Paul's rocket mass heater. |