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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:44:50+00:00 2026-05-13T21:44:50+00:00

What is actually passed in call by reference to a function? void foo(int &a,int

  • 0

What is actually passed in call by reference to a function?

void foo(int &a,int &b)

when I write

foo(p,q)

what is actually passed to the function. Is it the address of p and q?

  • 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-13T21:44:51+00:00Added an answer on May 13, 2026 at 9:44 pm

    What’s actually passed to the function is a reference. The named parameter b becomes a synonym for the argument object q.

    How the compiler probably implements this that the caller places the address of q on the stack or in a register before calling, and the callee uses that value to effect all accesses to b. But it could be misleading to describe that as “actually passing” a pointer, because parameter passing is a concept at the level of the C++ language, and at that level it is not the same concept as passing a pointer. For instance, when you pass a pointer you can pass a null pointer, but when you pass a reference you cannot (validly). So it’d be wrong to say they’re same thing.

    That said, the person implementing the compiler might describe it as “actually passing a pointer”, and you know what they mean. For comparison, if char variables occupy 4-byte stack slots in the calling convention, they might say that the compiler is “actually passing an int”. So it depends what “actually” is supposed to mean.

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

Sidebar

Related Questions

Suppose I have an arbitrary function: void someFunc(int, double, char); and I call someFunc(8,
Is it possible to actually use the type passed as a template for control
I am creating a factory that makes rooms, and it is passed an int
I would like to pass a pointer by reference to a function, such that
I like to initialize 2-dimensional arrays as vector<vector<int> >(x,y) . x is passed to
In the call pthread_create(&id, NULL, &start_routine, arg), is the thread id guaranteed to be
From The C Programming Language 2nd Edition: Since an argument of a function call
I wrote a function which I'm allowing a callback to be passed to. I
I have a recursive function which can be written like: void func(TypeName *dataStructure, LL_Node
Many people say that in Python arguments to functions are passed using a call-by-value

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.