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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:19:30+00:00 2026-05-15T14:19:30+00:00

From language design point of view , What type of practice is supporting operator

  • 0

From language design point of view , What type of practice is supporting operator overloading?

What are the pros & cons (if any) ?

  • 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-15T14:19:31+00:00Added an answer on May 15, 2026 at 2:19 pm

    EDIT: it has been mentioned that std::complex is a much better example than std::string for “good use” of operator overloading, so I am including an example of that as well:

    std::complex<double> c;
    c = 10.0;
    c += 2.0;
    c = std::complex<double>(10.0, 1.0);
    c = c + 10.0;
    

    Aside from the constructor syntax, it looks and acts just like any other built in type.


    The primary pro is that you can create new types which act like the built in types. A good example of this is std::string (see above for a better example) in c++. Which is implemented in the library and is not a basic type. Yet you can write things like:

    std::string s = "hello"
    s += " world";
    if(s == "hello world") {
        //....
    }
    

    The downside is that it is easy to abuse. Poor choices in operator overloading can lead to accidentally inefficient or unclear code. Imagine if std::list had an operator[]. You may be tempted to write:

    for(int i = 0; i < l.size(); ++i) {
        l[i] += 10;
    }
    

    that’s an O(n^2) algorithm! Ouch. Fortunately, std::list does not have operator[] since it is assumed to be an efficient operation.

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

Sidebar

Related Questions

I am asking this from a language design point of view. So I am
From a design point of view, why is that, in C++, there is no
This question is coming from a javascript point of view, but it certainly could
From discussions I've had about language design, it seems like a lot of people
I came from PHP language(codeigniter), but now I learning ASP.Net MVC :) In PHP
I'm porting some code from other language to Ruby, in my Class I need
I'm studying The C++ Programming Language from Bjarne Stroustrup and he talks about logical
is it possible to change the language from english to deustch for title send
Is it possible to derive the preferred language from a httpsession object (javax.servlet.http.HttpSession) ?
I am hearing buzzes about Go programming language from google. Wikipedia describes it like

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.