Method with the same name, same or different return type and difference in the parameters either in number or type
Login to rate this answer.
Praveen
Answered On : Jan 16th, 2012
We know that because of polymorphism, we can declare any number of function with change in signature.
Signature considers three parts
1. No.of parameters
2. Type of parameters
3. Order of parameters
The function which we are calling in our code is known to compiler at the time of compilation itself. This is called compile time polymorphism.
For example,
Let the functions are as follows,
Sum(int a, int b) { ------}
Sum(float a, int b) { ------}
Sum(int a, float b) { ------}
Sum(float a, float b) { ------}
In our code if we use sum(2,3) then at compilation time itself the compiler know that the function is Sum(int a, int b). This is called Compile time polymorphism.
Login to rate this answer.