File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the code trying to say between inheritance and aggregation?

 
sura watthana
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to figure out what the code below trying to say about the different between inheritance and aggregation. could somebody tell me, please? Thank you.




(added [C0DE][/C0DE] tags )
[ September 14, 2004: Message edited by: Barry Gaunt ]
 
Fletcher Estes
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aggregation means a collection of properties which defines a class. Your QueueByAggregation demonstrates this because it has a member variable (or property/attribute) which is the previously defined LinkedList. The nature of the QueueByAggregation is determined by what it is composed of, rather than what it is natively.

Inheritance means a class is a type of a superclass. In this case, your StackByInheritance is a type of LinkedList. It can do anything a LinkedList can do, and may be treated as a LinkedList by other classes. The StackByInheritance doesn't have a LinkedList, like the QueueByAggregation, it simply is one.

Hope this helps
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic