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

The Archive Base Latest Questions

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

I have some code written by someone else in which some functions take arguments

  • 0

I have some code written by someone else in which some functions take arguments whose data types are followed by a *&. I’m used to functions taking one or the other, e.g. taking a “double *” or a “double &” but not both. It would have thought they would just cancel out.

Here’s an example, and this is all from their code which supposedly works:

In a header file there’s a function declared as:

void someClass::foo(const unsigned int*& ubuff);

Then in my main file, there’s a pointer to some UINTs declared and initialized as:

unsigned int* pbuff = new UINT[n];

Then, the function someClass::foo is called as:

foo(pbuff);

When I compile, I get the error “cannot convert parameter 1 from ‘unsigned int *’ to ‘const unsigned int *&'”. If I change my function call to the following, it compiles ok:

foo((const unsigned int *&)(pbuff));

So, my questions are:

  1. What is the purpose of the *&? I.e., how is that different from * or & by themselves, and why do they not just cancel themselves out? And what does that make the function foo expect? An address? A value? The address of an address? It’s confusing.

  2. Is the fix of simply casting a “unsigned int*” to a “const unsigned int*&” ok or do I need to do something else?

Just another quick example, and this is from completely within a cpp file distributed by someone else, so I assume this compiled for them. They have a function call as

klabels = new int[sz];
EnforceLabelConnectivity(klabels, m_width, m_height, nlabels, numlabels, double(sz)/double(STEP*STEP));

When I try to build, I get an error “‘SLIC::EnforceLabelConnectivity’ : cannot convert parameter 1 from ‘int *’ to ‘const int *&'”.

Thanks as always.

  • 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-20T06:35:45+00:00Added an answer on May 20, 2026 at 6:35 am

    Well, I tried casting to a (const unsigned int *), and that did not work (wouldn’t build). In the end, I had to fully cast to a (const unsigned int *&) in the foo function example in my original post. Hope this helps. Thanks.

    As an aside, the reason I did not go the route of making pbuff const from the beginning in my main code is that it is passed to another function later on which does modify it, so I don’t think it would work to have it made const when declared.

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

Sidebar

Related Questions

I am starting to use some Java code which was written by someone else.
I have some code I've written in PHP for consuming our simple webservice, which
I am running some code that I have written in C which calls the
I'm writing some unittests for code written by someone else here at the office.
I have written some code in my VB.NET application to send an HTML e-mail
I have inherited some legacy PHP code what was written back when it was
I have some code which collects points (consed integers) from a loop which looks
I have some code in an IAuthorizationFilter which redirects the user to a login
I have a project (related to graph algorithms). It is written by someone else.
We've all been there. You have written some code and unit tests, the tests

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.