Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8192663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:13:45+00:00 2026-06-07T04:13:45+00:00

i am a beginner level programmer and have just started learning programming in C++,

  • 0

i am a beginner level programmer and have just started learning programming in C++,

i had a look at a feature called “FUNCTION OVERLOADING” and while i have understood the purpose and implementation at the code level, i haven’t understood how it is implemented at the compiler level that is how does a compiler differentiates between the signature of the different functions with same name and would

return-type func-name (data-type 1 , data-type-2);

would have the same signature as

return-type func-name (data-type 2 , data-type-1);

and does the same thing applies to overloaded constructors too ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:13:46+00:00Added an answer on June 7, 2026 at 4:13 am

    The compiler uses a technique known as name mangling.

    Briefly, the compiler encodes the number and type of the arguments into the actual name written into the object file. There are a few examples in the Wikipedia article on the subject, including examples from C++.

    As a specific example, I’ve used g++ on a Mac to compile the following C++ file:

    test.cpp

    int f(int x) {}
    
    int f(double x, char y) {}
    

    with

    g++ -S test.cpp
    

    This results in the assembly language file (elided somewhat):

    test.s

    .globl __Z1fi
    __Z1fi:
        pushq   %rbp
        movq    %rsp, %rbp
        movl    %edi, -4(%rbp)
        leave
        ret
    .globl __Z1fdc
    __Z1fdc:
        pushq   %rbp
        movq    %rsp, %rbp
        movsd   %xmm0, -8(%rbp)
        movb    %dil, -12(%rbp)
        leave
        ret
    

    The important part here is that the functions are called __Z1fi and __Z1fdc in the assembly language output, which the linker will see. You can probably infer that f is the name of the function, and for arguments, we have i (int) and dc (double and char). Note that order of arguments is encoded too!

    Now consider what would happen if you had

    int f(int x) {}
    int f(int y) {}
    

    This is of course not an acceptable situation as far as the language is concerned, since a call like f(10) could not be resolved. Theoretically a language could specify that the second declaration replaces the first, but C++ does not do this. This is simply an illegal overloading.

    It turns out that name mangling actually shows why this should be an error. The compiler would try to make two distinct functions with the name __Z1fi (the actual name is not defined by the language but is compiler dependent). We can’t have two identically named functions in a program at this level.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

query level: beginner As part of a learning exercise I have written code that
Right now I'm reading a beginner-level book called 'Programming Embedded Systems'. It has one
I'm a beginner level programmer trying to make a game app for the iphone
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Question : Beginner Level Code: Pure Javascript I had created a web page in
This is a beginner level question for asp.net MVC I have the following code
i am writing javascript code on nodepad++,i am at beginner level and write just
level: beginner the following code will print 'False' def function(x): if len(x) == 5:
I'm still a beginner to programming in high-level programming languages, so I don't know
This is a beginner-level question. I have a catalog of mtypes: mtype_id name 1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.