Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inheritance functionality with out extends

 
deepa sabbani
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to achieve inheritance functionality with out using extends or implements keyword?
 
Andre Brito
Ranch Hand
Posts: 95
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe importing a package?
Ok, it's not very usual and right, but it's a way, isn't it?
But why you can't use implements or extends?
 
deepa sabbani
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we achieve through composition
 
amitabh mehra
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by deepa sabbani:
can we achieve through composition


Composition is different from inheritance. It is basically HAS-A relationship where as inheritance is IS-A relationship. If you are using composition, it would mean that you are using the other object's functionality. Its just a design issue as to which technique you want to choose. You can take a look at inheritance vs composition
[ June 05, 2008: Message edited by: amitabh mehra ]
 
Henry Wong
author
Marshal
Pie
Posts: 21510
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by deepa sabbani:
can we achieve through composition


Sure. You can simulate it. But why?

I guess if you have some sort of mechanism that references through composition, then have a relationship table (along with method jump table), you can simulate inheritence -- provided that everyone uses your mechanism for calling / casting, etc. But this would be a lot of work to simulate something that is already supported.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic