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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:43:51+00:00 2026-05-30T19:43:51+00:00

There seems to be an issue with my dequeue function within a queue class

  • 0

There seems to be an issue with my dequeue function within a queue class that I have. My dequeue function which is part of the position class, is not returning the correct values that have been enqueued into the list.

The values that have been enqueued are which is a position object, are 2,1 and -1, but when I dequeue that object i get 2,506216, and -1; When I assign the *pos ponter to an object I am left with the default values;The enqueue function seems to be working correctly for when I check the ptr values they are correct.

//position constructor
front = back = &header;

        struct Posnode
        {   
           Position *pos;
           Posnode *next;    
        };
    class Position
    private:
              Posnode *front,*back,header;
void Position::dequeue(Position&p)
{
    Posnode *ptr=front->next;
    front->next = ptr->next;
    p = *ptr->pos;
    p.geta();//checking for values but am left with the default

    if (back == ptr)
    {
        back = front;
    }
    delete ptr;

}
v

oid Position::enqueue(Position n) //assigning Position object to end of queue
    {
        Posnode *ptr = new Posnode;
        ptr-> pos =  &n;
        back->next = ptr;
        back = ptr;

        return;
    }

Position copy,intial(5);
copy = intial;

        if (copy.ismovelegal(posmoves, r))
        {
            copy.makemove(posmoves, r);


            if (intial.solved(copy))
            {
                cin.get();
            }
            else
            {
                p.enqueue(copy);


            }
        }
        copy.free();//clearing object private memebers
    }
    intial.free();

    p.dequeue(o);//copy that was previous enqued is not enqued
    o.geta();
  • 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-30T19:43:52+00:00Added an answer on May 30, 2026 at 7:43 pm

    Just Check out the Implementation of Deque first and then try your own. If its some syntax or semantic error post minimal code that reproduces your code.

    this link might help you. Deque Implementation

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

Sidebar

Related Questions

This query is not returning any result as there seems to be an issue
There seems to be a bug in a Wordpress PHP function that leaves whitespace
There seems to be an issue around generating IDs with indexers within the MVC
There seems to be an issue simulating the backspace key with java.awt.Robot . This
I have a survey on a website, and there seems to be some issues
There seems to be multiple extremes when supporting embeddable Java HTTP servers. I have
So there seems to be an issue with animating size transformations for UIButtons. Specifically,
On iPad Safari, there seems to be issue with popup. When a popup (opened
It appears after much searching that there seems to be a common problem when
I have a database in place with a client that seems to lose data

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.