What is Name Mangling and why is it necessary for C++ to support function overloading?
Last updated
Name mangling: the compiler encodes a function's name plus its parameter types, namespace and class scope into a unique linker symbol.
The linker matches plain symbol names only, so without mangling overloads like
f(int)andf(double)would collide as duplicate symbols.Return type is not mangled (so no overloading on return type alone). Use
extern "C"to disable mangling for C interop.