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

The Archive Base Latest Questions

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

My professor has asks us to reimplement all of the LinkedList functions from scratch.

  • 0

My professor has asks us to reimplement all of the LinkedList functions from scratch. However, since this is a beginner class, he has put a few stipulations on it. Below is the full assignment:

“For list, you must implement everything but get_allocator. For all functions that take an “iterator” as an argument, instead accept a node class. For all functions that return an iterator, return a node instead.”

Since LinkedList use pointers, I am not sure how to do return a node without just returning a pointer. What would be the syntax for returning a node pointed to by a pointer called *current?

I am also unsure how to format the functions. For example, what would be the syntax for changing the following function to accept a node class and then return a node(i don’t need the code for the function, just how to accept a node and return a node class):

iterator insert (iterator position, const int&x)
  • 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-30T23:06:38+00:00Added an answer on May 30, 2026 at 11:06 pm

    “For list, you must implement everything but get_allocator. For all
    functions that take an “iterator” as an argument, instead accept a
    node class. For all functions that return an iterator, return a node
    instead.”

    Since LinkedList use pointers, I am not sure how to do return a node
    without just returning a pointer. What would be the syntax for
    returning a node pointed to by a pointer called *current?

    I think your professor is talking about accepting and returning pointers (or references) to nodes, not node values (copying nodes). I can say that with some degree of confidence because that’s the only way to preserve the underlying semantics of std::list with a one-to-one translation of iterators to nodes (node pointers).

    However, if your nodes are just mere aggregates storing pointers themselves and don’t try to do any memory management, then you can get away with copying them around, but I’d go with pointers if in doubt.

    So, something like this:

    iterator insert(iterator position, const T& val)
    {
       ...
    }
    

    Would look like this for your practice homework:

    LinkedListNode* insert(LinkedListNode* position, const T& val)
    {
       ...
    }
    

    If you aren’t using templates and can just make it a list of integers or whatever:

    LinkedListNode* insert(LinkedListNode* position, int val)
    {
       ...
    }
    

    Hope later your professor will make you appreciate the power of the iterator-based versions as those allow you to write function templates that work not only on linked lists but any kind of sequence, for example.

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

Sidebar

Related Questions

So to make a long story short. A professor asked this question in class
My professor in C++ has shown us this as an example in overloading the
My professor has given me this assignment. Implement a generic function called Max, which
I have two tables Department Professor in which Department has an attribute called HeadID
I'm currently taking a math class in College called Scientific Computing and the professor
I am trying to write the strstr function from scratch. I went through my
My professor in the uni has asked me to design a simple website with
I have four classes. Class Person , and three more, Student , Professor ,
My professor, (for some unexplained reason) wants to change all input-output files of our
Preface: This question is about a project I am working on with a professor

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.