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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:23:44+00:00 2026-05-13T16:23:44+00:00

Queue and Stack are a structures widely mentioned. However, in C++, for queue you

  • 0

Queue and Stack are a structures widely mentioned. However, in C++, for queue you can do it in two ways:

#include <queue>
#include <deque>

but for stack you can only do it like this

#include <stack>

My question is, what’s the difference between queue and deque, why two structures proposed? For stack, any other structure could be included?

  • 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-13T16:23:44+00:00Added an answer on May 13, 2026 at 4:23 pm

    Moron/Aryabhatta is correct, but a little more detail may be helpful.

    Queue and stack are higher level containers than deque, vector, or list. By this, I mean that you can build a queue or stack out of the lower level containers.

    For example:

      std::stack<int, std::deque<int> > s;
      std::queue<double, std::list<double> > q;
    

    Will build a stack of ints using a deque as the underlying container and a queue of doubles using a list as the underlying container.

    You can think of s as a restricted deque and q as a restricted list.

    All that is necessary is that the lower level container implements the methods needed by the higher level container. These are back(), push_back(), and pop_back() for stack and front(), back(), push_back(), and pop_front() for queue.

    See stack and queue for more detail.

    With respect to the deque, it is much more than a queue where you can insert at both ends. In particular, it has the random access operator[]. This makes it more like a vector, but a vector where you can insert and delete at the beginning with push_front() and pop_front().

    See deque for detail.

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

Sidebar

Ask A Question

Stats

  • Questions 311k
  • Answers 311k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The problem was the transaction log was full preventing any… May 13, 2026 at 10:22 pm
  • Editorial Team
    Editorial Team added an answer The typical way to do this is to read the… May 13, 2026 at 10:22 pm
  • Editorial Team
    Editorial Team added an answer Basically, a basic principle with SVN is that : When… May 13, 2026 at 10:22 pm

Related Questions

I'm implementing generic, persistent .NET collections based on top of the ESENT database engine
My program, alas, has a memory leak somewhere, but I'll be damned if I
In the 10 years I've been programming, I can count the number of data
I'm trying to build a sequence that determines the order to destroy objects. We
Ok guys, just a quick question hopefully someone can find my mistake quickly, but

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.