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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:31:41+00:00 2026-05-28T06:31:41+00:00

I have a trouble with references. Consider this code: void pseudo_increase(int a){a++;} int main(){

  • 0

I have a trouble with references.
Consider this code:

void pseudo_increase(int a){a++;}  
int main(){  
    int a = 0;
    //..
    pseudo_increase(a);
    //..
}

Here, the value of variable a will not increase as a clone or copy of it is passed and not variable itself.
Now let us consider an another example:

void true_increase(int& a){a++;}
int main(){  
    int a = 0;
    //..
    true_increase(a);
    //..
}

Here it is said value of a will increase – but why?

When true_increase(a) is called, a copy of a will be passed. It will be a different variable. Hence &a will be different from true address of a. So how is the value of a increased?

Correct me where I am wrong.

  • 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-28T06:31:42+00:00Added an answer on May 28, 2026 at 6:31 am

    Consider the following example:

    int a = 1;
    int &b = a;
    b = 2; // this will set a to 2
    printf("a = %d\n", a); //output: a = 2
    

    Here b can be treated like an alias for a. Whatever you assign to b, will be assigned to a as well (because b is a reference to a). Passing a parameter by reference is no different:

    void foo(int &b)
    {
       b = 2;
    }
    
    int main()
    {
        int a = 1;
        foo(a);
        printf("a = %d\n", a); //output: a = 2
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have trouble when designing classes like this class C1 { public: void foo();
I have trouble finding way to correctly refactor this code so that there would
i have trouble with building some projects. please consider this scenario: i have 2
I have trouble with the following piece of code. When I go through with
iI have some trouble getting sth like this to work in java: public class
Updated This is the method that gives me trouble: void A::normalizeUrls() { for (set<CUrl>::iterator
I have trouble with pointers and references to doubles. I want to access elements
The code that I am having trouble with is this line: result.addElement(&(*(setArray[i]) + *(rhs.setArray[j])));
I am having trouble understanding this code. All I really need is to modify
I have an existing list instance, which in live code has references throughout. When

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.