What is Name Mangling and why is it necessary for C++ to support function overloading?

Last updated 21 June 2026

  • 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) and f(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.

  • https://utkrusht.ai/blog/cplusplus-interview-questions
  • https://roadmap.sh/questions/cpp
  • https://internshala.com/blog/cpp-coding-interview-questions/
All C++ interview questions