I've read in an article that a compiler changes the names (name mangling) of functions (that have same names) to avoid names conflict.
Consider following example.
void fun(int x)
{
cout<<x<<endl;
}
void fun(float x)
{
cout<<x<<endl;
}
int main()
{
fun(10);
fun(10.5f);
return 0;
}
Above is a very simple example for function overloading. Here when code is compiled the compiler will change the function name so that linker can link between two different calls.
Question: What is the need of mangling?
Since the arguments have different datatype, that could have been enough to link with proper function. Why does then, the compiler perform Name Mangling?