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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:26:30+00:00 2026-06-14T00:26:30+00:00

I have a program in which a user enters in the number of queues

  • 0

I have a program in which a user enters in the number of queues that they want. Is it possible for my program to somehow then take that number and dynamically create queues (names and all). Also, once the queues are created, I would like to be able to loop through them, so I want to put them in an array called arrayOfQueues. The last thing to note is that the queues hold a struct called Process.

The following code might help set up my scenario better than I can type it:

UPDATED:

void function(int numQueues){
vector<queue<Process>> vectorOfQueues;
for(int i=0; i<numQueues; i++){
    vectorOfQueues.push_back(queue<Process>());
}
  • 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-14T00:26:32+00:00Added an answer on June 14, 2026 at 12:26 am

    If your concern is only to create an iteratable collection of queues, do as Kerrek suggests and use a vector of queues. But you say you want to name them. In that case you may want to keep them in an std::unordered_map<std::string,std::queue<Process>> in order to access them through their name.

    Regarding your update, it’s much too complicated. The same can be achieved easier:

    std::vector<std::queue<Process>> vectorOfQueues(numQueues,std::queue<Process>{});
    

    or

    std::vector<std::queue<Process>> vectorOfQueues;
    vectorOfQueues.resize(numQueues);
    

    is sufficient.

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

Sidebar

Related Questions

I have this following program which gets the number of files from user, then
I have a program which has a text box that the user can edit.
I have a program in which a user selects a row in a Datagrid
I have a project to create a program, which prevents the user from escaping
I have a program which creates JButtons which are then added to a JPanel
I have a program which dynamically generates a GUI. I don't know how many
So I'm building a program which takes ints from user input. I have what
I have a simple program test which gets a number as input and prints
I have an assignment to Write a C program that allows a user to
I am writing a program, that is encrypting a number, entered by user. Encryption

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.