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

  • Home
  • SEARCH
  • 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 5953543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:50:28+00:00 2026-05-22T17:50:28+00:00

As per the comment under this answer , references were introduced primarily to support

  • 0

As per the comment under this answer, references were introduced primarily to support operator overloading which quotes Bjarne Stroustrup:

References were introduced primarily
to support operator overloading. C
passes every function argument by
value, and where passing an object by
value would be inefficient or
inappropriate the user can pass a
pointer. This strategy doesn’t work
where operator overloading is used. In
that case, notational convenience is
essential so that a user cannot be
expected to insert address− of
operators if the objects are large.

Which implies that operator overloading can’t work with pointer. But it doesn’t clearly explain why operator overloading with pointers can’t work. Why wouldn’t operator overloading work for pointers?

IMO where references are used, pointers can also be used in its place.

  • 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-22T17:50:28+00:00Added an answer on May 22, 2026 at 5:50 pm

    Because if it was allowed, then it would not look good, and wouldn’t be as intuitive as its with reference.

    Suppose it is allowed, then you would write:

    struct A{};
    A a, *pa, b;
    
    a = pa ;//doesn't look good, also not intuitive. (not real C++)
    

    It doesn’t look good, because on left side you’ve non-pointer, on right side you’ve pointer. Looks very very weird. Also, since the types don’t match, it doesn’t look very intuitive as to what exactly its doing. I mean, you’re assigning pointer to a non-pointer; what such an assignment is supposed to do? Copying the content of the address pointed to by pointer to the destination (non-pointer) is not very inttuitive.

    On the other hand, as its allowed with reference (the reality, not a supposition):

    a = b; //looks good, intuitive, as now both side is same type
    

    With reference, you’ve both side same type, its only when b gets passed to operator=() as argument, it is passed by reference (or say by pointer, as references are syntactic sugar of pointers.) to avoid unnecessary copy, which in turn doesn’t hinder performance, as it would if it is passed by value.

    It would be also interesting to note that not only b is passed by reference (or pointer underneath), a also gets passed to the function by pointer, because we know in the function, the keyword this is actually a pointer.

    So references were introduced in C++, to make whole thing look good and intuitive for programmers, otherwise they’re pointers underneath. In fact, most compilers implement references using pointers (pointer-mechanism) internally.

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

Sidebar

Related Questions

Per this helpful article I have confirmed I have a connection pool leak in
I was reading a comment about server architecture. http://news.ycombinator.com/item?id=520077 In this comment, the person
as per the title; is it possible to have nested comments in valid HTML?
I'm optimizing some frequently run Perl code (once per day per file). Do comments
Per man pages, snprintf is returning number of bytes written from glibc version 2.2
Per the Java documentation, the hash code for a String object is computed as:
Per version (1.0, 1.1, 2.0, 3.0, 3.5), how many classes are in the .NET
Per the example array at the very bottom, i want to be able to
As per my understanding stateless session beans are used to code the business logic.
As per the Emacs docs , every time you open a file, Emacs changes

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.