c# - Types of polymorphism. More than one? -
i still in college , remember hearing 1 type of polymorphism when learning java; however, when in c# class, remember professor talking 4 types of polymorphism.
i aware of subclassing , defining specific behavior within more specific classes, , being able call specific behaviors single method in base class because of interface signature.
what other types, , of big of importance type taught above? why there not taught?
yes there 4 kinds of polymorphism
overloading (same function names, different parameter types. includes operator overloading , done @ compile time)
parametric polymorphism (these templates in c++) compile time
subtype polymorphism (if function has parameter subtype, example car->honda, f(car), function f accept f(honda) well.) runtime
parameter coercion (this implicit type conversion. example, function might require double/real/float, accept int , implicitly upcast parameter) compile time
reference:
- "on understanding types, data abstraction, , polymorphism" cardelli & wegner.
Comments
Post a Comment