function overloading


if you have in a file
int fn(int,int,int);
float fn(int,int);
it compiles fine
but if you have
int fn(int,int);
float fn(int,int);
it gives compilation error
so, is the following an example of function overloading?
int fn(int,int,int);
int fn(int,int);


why does
int fn(int,int,int);
float fn(int,int);
compile fine?
When you call a function, the compiler needs to be able to identify which function is being called.

Given a function int fn(int,int); and another function float fn(int,int); there is no way to know which function is being called in the following code:
 
fn(3,4);


If the compiler doesn't know what function you're trying to call, it stops with an error.
Topic archived. No new replies allowed.