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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:42:06+00:00 2026-05-26T23:42:06+00:00

Please note my homework tag. As with all homework, helpful suggestions over straight answers

  • 0

Please note my homework tag. As with all homework, helpful suggestions over straight answers to actual coding is appreciated. Feel free to answer any of my conceptual questions straight forwardly, though.

Hello,

My professor assigned us a doubly linked list for homework, and I was avoiding asking for help until I absolutely needed it, and here I am.

He provides us header files, which we then have to make a class for, and must follow the header file perfectly. The way he does his copy constructor is that he makes us write a helper function that we just have the copy constructor call.

I can do this easily, on a normal case, but this time he has given us a very bizarre signature for the helper function:

// copys chain at oldHead to newHead.
static void copy(Elem *&newHead, const Elem *oldHead)

This is to copy a chain of structs called Elems:

struct Elem 
{
    Information info;
    Elem *next;
    Elem *back;
};

I guess I’m mostly confused as to what the whole Elem *& business because, from what I remember, don’t & and * cancel each other out?

Thanks, any and all help is really appreciated! Hopefully this will help other people in my position in the future:)

  • 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-26T23:42:07+00:00Added an answer on May 26, 2026 at 11:42 pm
    static Elem* copy(const Elem *oldHead)
    

    Could have been a potential function. You take the old Head and return the new cloned Head.

    What he chose is passing the pointer by reference.

    If it was simply

    static void copy(Elem * newHead, const Elem *oldHead)
    {
        newHead = new Elem();
    }
    

    something like above. Any changes to newHead is not visible to outside the function.

    This is the same below. x is passed by value. Any changes to x are forgotten after the function Addten returns. Your x just happens to be a pointer.

       void Addten( int x )
        {
           x = x + 10;
        }
    
        int x = 10;
        Addten( x );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: Please do not tag this as homework! I am not a student and
Please note that this is not homework and i did search before starting this
Please note where I have the NSLOG. All it is displaying in the log
Please note that I have already been through similar questions and their answers here
Please note, I am a beginner with all of this. I am trying to
Please note this link Render HTML as an Image is not helpful. In previously
Please note this application will never be running on a server system. I am
Please note that I'm not asking how but why. And I don't know if
[Please note that this is a different question from the already answered How to
(Please note that I have seen a similar question on StackOverflow recently, however I

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.