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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:28:26+00:00 2026-05-12T20:28:26+00:00

Trying not to lose it here. As you can see below I have assigned

  • 0

Trying not to lose it here. As you can see below I have assigned intFrontPtr to point to the first cell in the array. And intBackPtr to point to the last cell in the array…:

bool quack::popFront(int& nPopFront)
{   
    nPopFront = items[top+1].n;
    if ( count >= maxSize ) return false;
    else
    {
        items[0].n  = nPopFront;
        intFrontPtr = &items[0].n;
        intBackPtr  = &items[count-1].n;
    }
    for (int temp; intFrontPtr < intBackPtr ;)
    {
         ++intFrontPtr;
         temp = *intFrontPtr;
        *intFrontPtr = temp;
    }
    return true;
}

In the else statement I’m simply reassigning to ensure that my ptrs are where I want them. For some reason I’m popping off the back instead of off the front.

Anyone care to explain?

  • 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-12T20:28:26+00:00Added an answer on May 12, 2026 at 8:28 pm

    I’m not entirely sure I understand what you’re trying to do, but if I;m guessing right you’re trying to ‘pop’ the 1st element of the array (items[0]) into the nPopFront int reference, then move all the subsequent elements of the array over by one so that the 1st element is replaced by the 2nd, the 2nd by the 3rd, and so on. After this operation, the array will contain one less total number of elements.

    Not having the full declaration of the quack class makes most of the following guesswork, but here goes:

    I’m assuming that item[0] represents the ‘front’ of your array (so it’s the element you want ‘popped’).

    I’m also assuming that ‘count` is the number of valid elements (so item[count-1] is the last valid element, or the ‘back’ of the array).

    Given these assumptions, I’m honestly not sure what top is supposed to represent (so I might be entirely wrong on these guesses).

    Problem #1: your nPopFront assignment is reversed, it should be:

    nPopFront = items[0].n;
    

    Problem #2; your for loop is a big no-op. It walks through the array assigning elements back to their original location. I think you want it to look more like:

    for (int i = 1; i < count; ++i)
    {
        items[i-1].n = items[i].n;  // move elements from back to front
    }
    

    Finally, you’ll want to adjust count (and probably top – if you need it at all) before you return to adjust the new number of elements in the data structure. The whole thing might look like:

    bool quack::popFront(int& nPopFront)
    {   
        if ( count >= maxSize ) return false;
        if ( count == 0 ) return false; // nothing to pop
    
        nPopFront = items[0].n;
        intFrontPtr = &items[0].n;      // do we really need to maintain these pointers?
        intBackPtr  = &items[count-1].n;
    
        for (int i = 1; i < count; ++i)
        {
            items[i-1].n = items[i].n;  // move elements from back to front
        }
    
        count -= 1;     // one less item in the array
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

require('fortunes') fortune('106') Personally I have never regretted trying not to underestimate my own future
I have two classess and a Userform. I am trying not to use any
I'm trying to not repeat code, so I have a method that does a
How can I disable tinyMCE? I'm not trying to make tinyMCE not exist, just
Hope someone can help. Apologies for not being well informed on htaccess. I have
I am not trying to create a BOOT_COMPLETED receiver (and doing so would not
Premise: I'm not trying to reinvent the wheel, I'm just trying to understand. Output
Please understand that I am not trying to start a flame war. I am
No, I am not trying to do anything evil. There is a discussion website
I'm playing around with templates. I'm not trying to reinvent the std::vector, I'm trying

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.