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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:03:14+00:00 2026-05-26T17:03:14+00:00

I am adding strings such as B1, P4, B4 B2, P6 .. etc to

  • 0

I am adding strings such as B1, P4, B4 B2, P6 .. etc to the list. I am trying to move items from the list to either a stack or a queue, until the list is empty. So if the items letter is P, i store it on a queue(back or front it doesn’t matter). If the letter is B then i store it on a stack. I tried implementing it like this but I get this error:

Boxes\main.cpp||In function 'int main()':|
Boxes\main.cpp|54|error: no matching function for call to 'std::queue<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::deque<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\bits\stl_queue.h|218|note: candidates are: void std::queue<_Tp, _Sequence>::push(const typename _Sequence::value_type&) [with _Tp = std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, _Sequence = std::deque<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::list<std::b|
Boxes\main.cpp|56|error: no matching function for call to 'std::stack<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::deque<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\bits\stl_stack.h|182|note: candidates are: void std::stack<_Tp, _Sequence>::push(const typename _Sequence::value_type&) [with _Tp = std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, _Sequence = std::deque<std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::list<std::b|

Any suggestions will be appreciated.

Here is what I have:

#include <iostream>

using namespace std;

#include <list> 
#include <queue>
#include <stack>
template <typename T>                       // prototype for client function
void print(list<T> &);

int main()
{
    list<string> lst;
    queue< list<string> > package;
    stack< list<string> > box;
    string choice, str;
    string::size_type pos,  start_position=0;
    bool choice_flag = true;

    do{
        cin >> choice;
        if(choice == "QUIT"){
            choice_flag = false;
            break;
        }
        else{
            lst.push_back(choice);
        }
    }while(choice_flag);

    cout << "the size of the list is " << lst.size() << endl;

    if (lst.empty() == true)
        cout << "the list is empty" << endl << endl;
    else
        cout << "the list is not empty" << endl << endl;

    print(lst);

    // attempt to move from list lst and push onto queue or stack
    while(!lst.empty()){
        str = lst.front();
        if(str.find('P' ,0))
            package.push(str);
        else
            box.push(str);
    }

    return 0;
}
  • 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-26T17:03:15+00:00Added an answer on May 26, 2026 at 5:03 pm

    If you want a queue and stack of strings change:

    queue< list<string> > package;
    stack< list<string> > box;
    

    to:

    queue< string > package;
    stack< string > box;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JUnit test that tests adding Strings to a Dictionary custom type.
What's the best way of adding spaces between strings myString = string.Concat(a, ,b) or
I need to manipulate large strings in Java (deleting and adding the deleted chars
How does performance for reading/adding values from/to Dictionary(Of String, SomeReferenceType) depend on the number
I'm trying to split a string up into words and punctuation, adding the punctuation
Adding an element to the head of an alist (Associative list) is simple enough:
I have a large list (over 200,000) of strings that I'd like to compare
From ant, we want to extract a line from an old /etc/shadow file, capturing
I'm adding UTC time strings to Bitbucket API responses that currently only contain Amsterdam
I've been trying to port my pThread classes over to iOS. As such I

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.