First page Back Continue Last page Summary Graphics
Polymorphism
Coercion polymorphism
- up-cast parameter (eg: int i = 1; sqr(i))
Overloading polymorphism
- same function name with different parameter types. eg: print(int) and print(char *)
Parametric polymorphism
- Parametric functions
- ML: sort :: (a,a->int), list(a) -> list(a)
- C++: template<class A>
- vector<A> sort(vector<A>, int (*)(A,A))
- Parametric type classes
- Parametric classes (more about classes in next slide)
Notes: