Function overloading simply means that the same function is defined more than once, but each time with a different formal parameter list. The parameter lists must differ at least in one of it’s elements type. When the compiler encounters a function call, it will look at the function parameters to decide which one of the defined functions it should call. This can be useful when the same function must be defined for different types. For example, in the RTL, the Dec procedure could be defined as:
... Dec(Var I : Longint;decrement : Longint); Dec(Var I : Longint); Dec(Var I : Byte;decrement : Longint); Dec(Var I : Byte); ... |