Win a copy of Design for the Mind this week in the Design 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic