This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

polymorphism and overloading

 
ali farid
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is overloading by any means concerned with polymorphism ?
 
Avijeet Dash
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Polymorphisim is simply 'same name and many forms'.
static polymorphism:
It can be in the form of operator overloading (c++, or '+' for string concatenation in Java ). It can be function overloading i.e. same function name with different input argumant types in the same class or sub classes.
dynamic polymorphism:
function overriding can be done only in subclasses, which means same function name and input arguments and the implementation is different.
 
Piotr Aniola
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The generally accepted definition of polymorphism is:
"Ability to hide multiple implementations behind a single interface."
So I agree function overloading is polymorphism. So is operator overloading. Any kind of overloading will be polymorphic because the same interface is used to refer to different behaviours.
 
Mark Savory
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piotr,
Overloaded functions do not represent the same interface, so maybe your definition is refering to "dynamic polymorphism" mention by Avijeet in the previous message.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic