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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:43:32+00:00 2026-06-10T06:43:32+00:00

Im making a doublyLinkedList. The error is to do with my Remove method. I

  • 0

Im making a doublyLinkedList. The error is to do with my Remove method. I cant figure this out. does anyone know?

Here is where the error is?

Error 1 error C2027: use of undefined type
‘DoublyListNode’ c:\users\conor\documents\college\c++\projects\repeat
– doublylinkedlist\repeat – doublylinkedlist\doublylinkedlist.h 230 1 Repeat – DoublyLinkedList

// -------------------------------------------------------------------------------------------------------
//  Name:           Remove
//  Description:    Removes the node that the iterator points to, moves iterator forward to the next node.
//  Arguments:      p_iterator: The iterator to remove
//                  isForward: Tells which direction the iterator was going through the list
//  Return Value:   None.
// -------------------------------------------------------------------------------------------------------
void Remove(DoublyListIterator<Datatype>& m_itr)
{
    DoublyListNode<Datatype>* node = m_head;
    // if the iteratordoesn’t belong to this list, do nothing.
    if (m_itr.m_list != this)
        return;
    // if node is invalid, do nothing.
    if (m_itr.m_node == 0)
        return;
    if (m_itr.m_node == m_head)
    {
        // move the iteratorforward and delete the head.
        m_itr.Forth();
        RemoveHead();
        m_size--;
    }
    else
    {
        // scan forward through the list until you find
        // the node prior to the node you want to remove
        while (node->m_next != m_itr.m_node)
            node = node->m_next;
        // move the iterator forward.
        m_itr.Forth();
        // if the node you are deleting is the tail,
        // update the tail node.
        if (node->m_next == m_tail)
        {
            m_tail = node;
        }
        // delete the node.
        delete node->m_next;
        // re-link the list.
        node->m_next = m_itr.m_node;
        m_size--;
    }
}

If anymore code is needed just ask. I do not want to put lots of code on Stack overflow users.

  • 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-06-10T06:43:33+00:00Added an answer on June 10, 2026 at 6:43 am

    You are checking for tail node but not for a node between head and a tail.You are breaking the chain by deleting the node even before linking it to the next member.

    Let us analyze:-

    while (node->m_next != m_itr.m_node)
                node = node->m_next;
    

    after the loop node->m_next points m_itr.m_node

        delete node->m_next;
        // re-link the list.
        node->m_next = m_itr.m_node;
    

    You are assigning a deleted node!!!!

    Change the code:-

    node->m_next = m_itr.m_node;
    delete m_itr;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making a server in java, First off, Here's the code. AnsiConsole.out.println(This is a Test.);
Im making a doublyLinkedList. The error is to do with my getIterator method. I
Making a piano/keyboard application and trying to figure out the best way to set
making a call to a web service method with nusoap returns an error array(3)
Making a simple application, so when the user logs out of Windows, it of
Making an adobe flex ui in which data that is calculated must use proprietary
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
Making a new shooter game here in the vein of Galaga (my fav shooter
Making an Flex App. Just wondering if anyone has created something that fits automatically
Does making a class field volatile prevent all memory visibility issues with it in

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.