| View previous topic :: View next topic |
| Author |
Message |
hack_tick Guest
|
Posted: Fri Feb 24, 2006 2:06 am Post subject: Static Ploymorphism |
|
|
Hi Guys!
Is function overloading a kind of static polymorphism? |
|
| Back to top |
|
 |
Jaspreet Guest
|
Posted: Fri Feb 24, 2006 2:06 am Post subject: Re: Static Ploymorphism |
|
|
hack_tick wrote:
| Quote: | Hi Guys!
Is function overloading a kind of static polymorphism?
|
I may be wrong but I suppose function templates is a case of static
polymorphism. Function over-loading is not considered a correct example
of static polymorphism. It (overloading) is sometimes termed as ad-hoc
polymorphism. Let the experts throw more light on it. |
|
| Back to top |
|
 |
Alf P. Steinbach Guest
|
Posted: Fri Feb 24, 2006 10:06 am Post subject: Re: Static Ploymorphism |
|
|
* Jaspreet:
| Quote: | hack_tick wrote:
Hi Guys!
Is function overloading a kind of static polymorphism?
I may be wrong but I suppose function templates is a case of static
polymorphism. Function over-loading is not considered a correct example
of static polymorphism. It (overloading) is sometimes termed as ad-hoc
polymorphism. Let the experts throw more light on it.
|
It all depends on what one means by "polymorphism", which depends on
context.
In the most general meaning, yes, although function overloading is not
enough by itself. It requires some templated client code in order to
deal with different types in the same source code way. But templated
code could not do different things in the same way with different types
if there was no function or operator overloading (or other mechanism).
In the most common very narrow meaning we do not even consider static
polymorphism, e.g. the standard's "polymorphic class" (def: §10.3/1).
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? |
|
| Back to top |
|
 |
Axter Guest
|
Posted: Fri Feb 24, 2006 12:06 pm Post subject: Re: Static Ploymorphism |
|
|
hack_tick wrote:
| Quote: | Hi Guys!
Is function overloading a kind of static polymorphism?
|
Yes, it is static polymorphism.
C++ has one type of dynamic polymorphism, and two types of static
polymorphism.
1. Ad-hoc polymorphism (Function Overloading) [static binding]
2. Parametric polymorphism (Templates) [static binding]
3. Virtual methods (run-time) [dynamic binding]
Static polymorphism is resolved at compile time, which is unlike
dynamic polymorphism, which is resolved at runtime.
See following link:
http://en.wikipedia.org/wiki/Polymorphism_(computer_science) |
|
| Back to top |
|
 |
Guest
|
|
| Back to top |
|
 |
|