LearnFrenzy
Sign in Take a free test

Functions and Default Arguments · Functions MCQ · Question 18

Why does C++ use name mangling? Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 18 Back to Exercise

Why do C++ compilers mangle function names?

  • A To hide source code
  • B To encode parameter types in the symbol so overloaded functions get distinct names for the linker Correct
  • C To make programs smaller
  • D To support recursion
Correct Answer: Option B

add(int, int) and add(double, double) become different linker symbols. extern "C" disables mangling so C code can call the function.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links