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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:07:46+00:00 2026-06-12T06:07:46+00:00

At the line temp.insert(it); I keep getting the error No matching member function for

  • 0

At the line temp.insert(it); I keep getting the error No matching member function for call to insert, which means that at some point in my code temp became something other than a vector. anybody have any ideas?

#include <iostream>
#include <vector> 

using namespace std;

vector<int> removeDuplicates(vector<int> stuff)
{

vector<int> temp;
vector<int>::iterator it;

for(vector<int>::size_type i = 0; i < stuff.size(); i++){
    //iterator to find stuff
    it = find(stuff.begin(), stuff.end(), stuff);

    //if it not in temp then add it
    if (it == temp.end()) {
        temp.insert(it); //No matching member function for call to insert
    }
}

return temp;


}

int main(int argc, const char * argv[])
{


vector<int> values;
for(int i = 0; i < 5; i++){
    values.push_back(i);
    values.push_back(i+1);
}

removeDuplicates(values);
return 0;
}

well the answers helped me out a lot, but I decided to rewrite the code and here is what I got and it seems to work pretty well

#include <iostream>
#include <vector> 

using namespace std;

vector<int> removeDuplicates(vector<int> oldvector)
{

// newvector to hold non-duplicates
vector<int> newvector;

vector<int>::iterator it;



for(vector<int>::size_type i = 0; i < oldvector.size(); i ++){

    //If it find a value then it returns the first element
    it = find(newvector.begin(),newvector.end(), oldvector[i]);
    if(it == newvector.end()){
        newvector.push_back(oldvector[i]);
    }



}

return newvector;


}

int main(int argc, const char * argv[])
{


vector<int> values;
vector<int> newvalues;

for(int i = 0; i < 5; i++){
    values.push_back(i);
    values.push_back(i+1);
}



newvalues = removeDuplicates(values);

//Print out the vector without duplicates
for(vector<int>::size_type i = 0; i < newvalues.size(); i ++){
    cout << newvalues[i] << "\t";

}

return 0;
}

Thanks for the help with the original question, i learned a lot.

  • 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-12T06:07:47+00:00Added an answer on June 12, 2026 at 6:07 am

    The three (pre-C++11) valid signatures for std::vector::insert are:

    iterator insert ( iterator position, const T& x );
        void insert ( iterator position, size_type n, const T& x );
    template <class InputIterator>
        void insert ( iterator position, InputIterator first, InputIterator last );
    

    You chose invalid option #4:

    temp.insert(iterator);
    

    That option does not exist, you’ll have to chose from one of the three listed above.


    On a side note (as ildjarn pointed out), C++11 adds more… and takes a few away. Regardless, none of them would be valid the way you are calling it. See: http://en.cppreference.com/w/cpp/container/vector/insert

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

Sidebar

Related Questions

I'm running a resque job which contains following line: temp = %x(/usr/bin/java -jar /usr/local/tika/tika-app-1.0.jar
hey guys i got following error Undefined index: hname in C:\Temp\5Aug2010\job.php on line 38
I have some sprocs that need a temp table. In order not to hardcode
I'm getting the error Must declare @sales_total when I run this query: --temp Department
I am trying to multi insert in my table but getting error. My query
string temp is equal to ZERO:\t.WORD\t1 from my debugger. (the first line of my
My goal here is to open temp.php, explode by ### (line terminator), then by
Bottom Line Up Front Is there a succinct way that I can constrain the
I'm getting Incorrect Syntax Near ')' The line it references is oCN.Execute(sSQL) towards the
Rails 2.3.5 I need a temp work around for a script that only has

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.