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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:49:52+00:00 2026-05-21T06:49:52+00:00

i am having trouble inserting objects of type pair<int, int> into a queue. i

  • 0

i am having trouble inserting objects of type pair<int, int> into a queue. i am getting a strange error, and i have no idea how to go about fixing it. Can anyone help? the following is the code for the method, followed by the error messages. The first two errors are for the insert, the last is for the usage of the operator=, help with that too would be appreciated. Thanks!

pair<int,int>* bfSpanningTree(int theVertex)
{
    queue< pair<int,int> > pairq;
    queue<int> nodeq;
    if(linkedAdjacencyList[theVertex]->value == theVertex && linkedAdjacencyList[theVertex]->adj != NULL)
    {
        Node* whereto;
        whereto = linkedAdjacencyList[theVertex]->adj;
        while(whereto->adj != NULL)
        {
            pairq.push(pair< &whereto->value, &whereto->adj->value >);
            nodeq.push(whereto->value);
            whereto = whereto->adj;
        }
        while(!nodeq.empty())
        {
            whereto = linkedAdjacencyList[theVertex]->adj;
            while(whereto->adj != NULL)
            {
                pairq.push(pair<&whereto->value, &whereto->adj->value>);
                whereto = whereto->adj;
            }
        }
    }
    int i = 0;
    pair<int,int>* retVal;
    pair<int,int> tree[pairq.size()];
    while(!pairq.empty())
    {
        tree[i] = pairq.pop();
        i++;
    }
    retVal = tree;
    return retVal;
}

~UndirectedGraph()
{
    for (int i = 0; i < numVerticies; i++)
        delete[] linkedAdjacencyList[i];
}

errors:

hw8.h:181: error: wrong number of template arguments (1, should be 2)

/usr/include/c++/4.4/bits/stl_pair.h:67: error: provided for ‘template<class _T1, class _T2> struct std::pair’

hw8.h:190: error: wrong number of template arguments (1, should be 2)

/usr/include/c++/4.4/bits/stl_pair.h:67: error: provided for ‘template<class _T1, class _T2> struct std::pair’

hw8.h:200: error: no match for ‘operator=’ in ‘tree[i] = pairq.std::queue<_Tp, _Sequence>::pop [with _Tp = std::pair<int, int>, _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >]()’

/usr/include/c++/4.4/bits/stl_pair.h:68: note: candidates are: std::pair<int, int>& std::pair<int, int>::operator=(const std::pair<int, int>&)

  • 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-21T06:49:52+00:00Added an answer on May 21, 2026 at 6:49 am

    Lines of code like so:

    pairq.push(pair< &whereto->value, &whereto->adj->value >);
    

    should probably look like:

    pairq.push(make_pair(whereto->value, whereto->adj->value));
    

    or if the value members aren’t of type int:

    pairq.push(pair<int,int>(whereto->value, whereto->adj->value));
    

    Finally, queue::pop() doesn’t return anything, so you probably want:

    tree[i] = pairq.front();
    pairq.pop();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been having trouble getting my ASP.NET application to automatically log users into the
I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
I having trouble in dividing the HTML frames. I have been using the following
I am having trouble with IE7. I have a header, which is an IMG.
I'm having trouble getting a rotary encoder to work properly with AVR micro controllers.
I'm having trouble with global variables in php. I have a $screen var set
I am having trouble injecting AutoMapper into an ASP.NET MVC 2 application using Ninject.
I am having trouble injecting form data back into the form so the form
Im having trouble getting my head round subqueries in Mysql. Fairly simple ones are

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.