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 1009775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:58:48+00:00 2026-05-16T08:58:48+00:00

Sometimes, I felt method overloading may create confusion. class a { public: void copy(float

  • 0

Sometimes, I felt method overloading may create confusion.

class a {
public:
    void copy(float f);
    void copy(double d);
};

a me;
me.copy(1.2); // Not obvious at the first sight on which version we are calling.

A workaround on this is.

class a {
public:
    void copyFloat(float f);
    void copyDouble(double d);
};

However, having method with different name, to perform same functionality doesn’t seem a good idea as well. May I know, what do you consider, to choose among method overloading, or method with different naming?

  • 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-05-16T08:58:49+00:00Added an answer on May 16, 2026 at 8:58 am

    Overloading for sure.

    Okay, so it’s not “obvious” which function gets called (arguable)…so what? You don’t care that it can take different types of parameters, it just needs to do its thing. If you have different behavior based on different overloads, you’ve abused overloads, not pointed out a flaw in them.

    An example of abusing overloads:

    // good:
    struct has_properties
    {
        void property1(float); // set property1, which happens to be a float
        void property2(int); // set property2, which happens to be an int
    };
    
    // bad:
    struct has_properties
    {
        void property(float); // set property1, abusing that it's a float
        void property(int); // set property2, abusing that it's an int
    };
    

    Hopefully you see the problem here. If two functions have the same name, they should do the same thing.

    Even better, if you’re merely trying to allow the possibility for operating on different types, just use a template. (This arguably is a form of overloading.)

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

Sidebar

Ask A Question

Stats

  • Questions 532k
  • Answers 532k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer How about implementing an IValueConverter that builds the correct CompositeCollection… May 17, 2026 at 12:11 am
  • Editorial Team
    Editorial Team added an answer HTML5 supports these 2 tags (audio / video) which Safari… May 17, 2026 at 12:11 am
  • Editorial Team
    Editorial Team added an answer Use a handler and let the background thread notify the… May 17, 2026 at 12:11 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

After reading this post I kinda felt in the same position as the guy
What I mean by this, is that sometimes architects look to simplify and improve
Sometimes, I find myself in a situation where valid files are made invalid by
Sometimes it can be confusing reading code in instance members that refers to other
Sometimes with a complex header structure it happens some header is included, but it
Sometimes, when I upload files to ftp, and then download them, I face with
Sometimes, when fetching data from the database either through the python shell or through
Sometimes it would be useful to name variables like no programmer should name his
Sometimes I come across code such as this: import matplotlib.pyplot as plt x =
Sometimes I need to block access on a website, but I don't want to

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.