This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Has-a relationship

 
Stary Kapec
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class A {}
class B extends A {}
class C { B b; }

C has-a B, but my doubt is if C has-a A is also true, because B extends A

Thanks
 
Gavin Tranter
Ranch Hand
Posts: 333
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would have guessed that C HAS-A A, as B IS-A.
But the reference is actual to a class of type B, therefore I would say C dosnt HAVE-A A.

But that is just my guess, would like to know what others think
[ March 20, 2007: Message edited by: Gavin Tranter ]
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. C has A through B, would be more proper.

There is difference in saying "C has A" and "C has A through B."

1)C has A: Here A's methods will work on its data.

2)"C has A through B." : when Method overriding takes place, "B method may include its own data too".

Hope its clear.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic