Here's an example of polymorphism in C++:
int nth ( int a[] , int i ) { return a[i] ; }
double nth ( double a[] , int i ) { return a[i] ; }
One way to think of this is that there are two functions called nth
. One can be called with an int array and the other can be called with a double array. The function that is called is determined at compile time by looking at the type of the expression of the first argument.