• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inheritance functionality with out extends

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to achieve inheritance functionality with out using extends or implements keyword?
 
Ranch Hand
Posts: 95
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we achieve through composition
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic