Compile Time Overloading

What is the requirement of compile time overloading?

Questions by hellzangel_11

Showing Answers 1 - 9 of 9 Answers

Praveen

  • 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.

  Was this answer useful?  Yes

Mamta

  • Sep 14th, 2017
 

Compile time overloading or static binding or early binding means to have same method name with different arguments. Example
sample(int a)
sample(int a, int b)
sample(char a)
sample(int a, char b)
sample(int a, char b, string c)
All of these are example of compile time overloading.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions