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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:55:56+00:00 2026-05-12T13:55:56+00:00

I wrote a function along the lines of this: void myFunc(myStruct *&out) { out

  • 0

I wrote a function along the lines of this:

void myFunc(myStruct *&out) {
    out = new myStruct;
    out->field1 = 1;
    out->field2 = 2;
}

Now in a calling function, I might write something like this:

myStruct *data;
myFunc(data);

which will fill all the fields in data. If I omit the ‘&‘ in the declaration, this will not work. (Or rather, it will work only locally in the function but won’t change anything in the caller)

Could someone explain to me what this ‘*&‘ actually does? It looks weird and I just can’t make much sense of it.

  • 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-12T13:55:57+00:00Added an answer on May 12, 2026 at 1:55 pm

    The & symbol in a C++ variable declaration means it’s a reference.

    It happens to be a reference to a pointer, which explains the semantics you’re seeing; the called function can change the pointer in the calling context, since it has a reference to it.

    So, to reiterate, the “operative symbol” here is not *&, that combination in itself doesn’t mean a whole lot. The * is part of the type myStruct *, i.e. “pointer to myStruct“, and the & makes it a reference, so you’d read it as “out is a reference to a pointer to myStruct“.

    The original programmer could have helped, in my opinion, by writing it as:

    void myFunc(myStruct * &out)
    

    or even (not my personal style, but of course still valid):

    void myFunc(myStruct* &out)
    

    Of course, there are many other opinions about style. 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 310k
  • Answers 310k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried debugging it so that you can inspect… May 13, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer Context really helps when you have a much larger DOM… May 13, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer Checking out a branch moves the local HEAD pointer so… May 13, 2026 at 10:08 pm

Related Questions

I am doing a project converting some Pascal (Delphi) code to C++ and would
I understand the many benefits of providing an interface to access the members of
I'm trying to fix something in some Objective C++ (?!) code. I don't know
Let's say I have a function called DisplayWhiskers() which puts some slashes and backslashes

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.