Forums Register Login

Does is-a imply has-a ?

+Pie Number of slices to send: Send
class A { C c = new C(); }
class B extends A {}
1. B has-a C ?
class A { private C c = new C(); }
class B extends A {}
2. B has-a C ?
+Pie Number of slices to send: Send
Yup.
If B inherits from A, and A has an inheritable member c of type C, then B inherits that member and, therefore, B "has a" C.
In the second case, however, the member is private so it is not inherited. Therefore, in that case, B doesn't have a C.
[ July 18, 2003: Message edited by: Corey McGlone ]
+Pie Number of slices to send: Send
Thank you Corey.
I am getting is-a and has-a confused with class diagrams. I was thinking is-a is the inheritance arrow and has-a is the aggregation symbol. I first saw the terms is-a and has-a in the UML User's Guide.
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 618 times.
Similar Threads
HAS A
casting
Has-a relationship
Double Casting
Question on inheritance
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 23:34:58.