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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:10:19+00:00 2026-06-02T20:10:19+00:00

I have a question but I don’t know how to search about it, so

  • 0

I have a question but I don’t know how to search about it, so wanted to ask you.
It may sound simple but I’m a kind of a newbie.

I’m coding in C++. I have 20 values in an array. I do some work on them and after the calculation, I need to add a new value to these 20 values and need to delete the oldest variable. A kind of updating the array with new values.

For example:
My previous values : a,b,c,d, …. t
My current values : b,c,d,e …. u

This process will go on under a loop as long as the condition is not satisfied.

So, my question is: Is there any specific structure or method to perform this task or do I have to handle this work manually ? (Actually, I could do it by writing an impractical method which could be enough for me but I don’t think there might not be a dedicated stack structure for this work)

Thanks in advance.

  • 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-02T20:10:22+00:00Added an answer on June 2, 2026 at 8:10 pm

    Use std::queue or std::deque(difference that queue is FIFO(first in first out) when deque can remove elements from both sides):

    if (queue.size() == MAX_SIZE) {
        queue.pop_front();
    }
    queue.push_back(value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know if this question has been ask before. But I have a
may be i am going to ask some stupid question but i don't have
I have seen several threads about this question but I don't know why they
a simple question but I don't seem to have the right terminology to search
(I don't think I have titled this question correctly - but I don't know
I have one question. I made quick search on the site, but don't found
seems like a simple question but I don't know JavaScript too well and my
This may seem like a dumb question but I don't know how to do
First thing I know this is repeated question but I don't have problem in
I'm sure this is an easy question, but I don't have an answer for.

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.