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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:20:45+00:00 2026-05-27T06:20:45+00:00

What I used to know about c++ references is that: The reference should be

  • 0

What I used to know about c++ references is that:

  1. The reference should be initialized in the declaration statement
  2. The reference cannot be re-defined once defined

The following piece of code perfectly run on g++ 4.6.1, although it breaks #2:

int a = 10, b = 30;
int& x = a;
x = b;
  • 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-27T06:20:45+00:00Added an answer on May 27, 2026 at 6:20 am

    Jedi mindtrick:

    What helped me better understand references is to think of them as names for your variables. int& x = a just means that when you say x, you actually mean a.

    Think of references as an alias.

    This is pretty clear:

    int a = 10, b = 30;
    

    Think of this not as x = 10, but as "x is a different name for a".

    int& x = a;
    

    So now, x will still reference a, so you give a the value of b (30).

    x = b;
    

    At this point, x is still bound to a, you just changed its value.

    So, x == 30 and a == 30 at this point, but if you do:

    a = 10;
    

    x will also equal 10.

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

Sidebar

Related Questions

I currently don't know any thing about web services, except that they are used
If you followed a DM course, which textbook was used? I know about Data
I only know a small amount about .NET MVC and haven't used it barely
I know ClientID is used for javascript and UniqueId for server side and that
I know that CSS can be used to control the presentation of (X)HTML in
I know it is commonly used as a lock object, but is that really
I know that jQuery.extend can be used to add by own custom methods to
I know that the session is used for the database in Hibernate, but what
I know that generics are used to achieve type safety and i frequently read
I have used Java, C++, .Net. (in that order). When asked about by-value vs.

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.