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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:09:49+00:00 2026-06-02T18:09:49+00:00

This is a follow on from an earlier question about how to condense a

  • 0

This is a follow on from an earlier question about how to condense a switch statement. I have used the input provided earlier but I am getting errors about how to insert my elements into the vector, but I thought this was how you inserted a vector in C++?

std::queue<myStruct > myQueue1, myQueue2, myQueue3, myQueue4, myQueue5

void change(float posx, float posy, int idNumber){  
    myStruct newDir;
    newDir.psX = posx;
    newDir.psY = posy;

    std::vector< std::queue<myStruct> > myVector (5);

    myVector.begin();
    myVector.insert (myQueue1);
    myVector.insert (myQueue2);
    myVector.insert (myQueue3);
    myVector.insert (myQueue4);
    myVector.insert (myQueue5);


    if (idNumber >= 1 && idNumber<= 5){
        myVector[idNumber-1].push (newDir);
        }


}

TIA Any help appreciated.

  • 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-02T18:09:52+00:00Added an answer on June 2, 2026 at 6:09 pm

    vector::insert() is for inserting a new element at a particular position (so it needs a position parameter). You probably just want push_back() which will put the new item at the end of the vector. For this to work, you wouldn’t want to initialize your vector as you do (which puts five empty queues on the vector); just default initialize the vector:

    std::vector< std::queue<locaRef> > myVector;
    

    But there’s also the issue that your vector has elements with type std::queue<locaRef>, but the queues you’re putting on the vector are std::queue<MyStruct>. even if you fix the difference in types, you’ll need to keep in mind that what will get put on to the vector are copies of the queue, which may or may not be what you want. You may want the vector to take some kind of pointer or smart pointer to your queue objects if you don’t want copies.

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

Sidebar

Related Questions

This is a follow on from my previous question although this is about something
This is a follow-up to my earlier question I have written a script which
This is a follow up to the question I asked earlier. Basically I have
This is a follow-up to an earlier question here: CakePHP find statement for a
This is a follow on question to an earlier one. I have learned some
This is a follow up from a question of mine that was just answered
This is a follow-on from this question, in which I was trying to suppress
This is a follow-on question from the one I asked here . Can constraints
This question is a follow on from this one ... I am binding to
This is a follow-up to a question I'd asked earlier which phrased this as

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.