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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:24:42+00:00 2026-06-03T21:24:42+00:00

I have encountered a list of errors when i was trying to execute this

  • 0

I have encountered a list of errors when i was trying to execute this erase function to remove ‘2’ from my vector. I am not sure where is the problem. Help will be greatly appreciated!

STRUCT MyInt

struct MyInt
{
friend ostream &operator<<(ostream &printout, const MyInt &Qn)
{
   printout<< Qn.value << endl;
   return printout;
}

  int value;
  MyInt (int value) : value (value) {}
};

STRUCT MyStuff

struct MyStuff
{
  std::vector<MyInt> values;

  MyStuff () : values ()
  { }
};

MAIN

int main()
{
MyStuff mystuff1,mystuff2;

for (int x = 0; x < 5; ++x)
    {
        mystuff2.values.push_back (MyInt (x));
    }

vector<MyInt>::iterator VITER;
mystuff2.values.push_back(10);
mystuff2.values.push_back(7);

    //error points to the line below
mystuff2.values.erase(std::remove(mystuff2.values.begin(), mystuff2.values.end(), 2), mystuff2.values.end());

    return 0;

}

Error Messages

stl_algo.h: In Function ‘_OutputIterator std::remove_copy(_InputInputIterator, _InputIterator, const_Tp&) [with_InputIterator = __gnu_cxx:__normal_iterator > >, OutputIterator = __ gnu_cxx::__normal iterator > >, Tp = int]’

No match for operator==’

Erorr messages showed the partciular line violated practically stl_algo.h’s lines
Line 1267, 1190, 327, 1263, 208, 212, 216, 220, 228, 232, 236

  • 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-03T21:24:43+00:00Added an answer on June 3, 2026 at 9:24 pm

    You need to overload the == operator for class MyInt.

    For example:

    struct MyInt
    {
    
    friend ostream &operator<<(ostream &printout, const MyInt &Qn)
    {
       printout<< Qn.value << endl;
       return printout;
    }
    
    // Overload the operator 
    bool operator==(const MyInt& rhs) const
    {
      return this->value == rhs.value;
    }
    
      int value;
      MyInt (int value) : value (value) {}
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have encountered a very strange class not found problem in our web app
I have encountered the strange problem, that linux c++ compiler includes the files from
I have encountered a most annoying problem that occurs on the PWD variable when
I have encountered a rather nasty problem with the DataGridView control (Windows.Forms, .NET Framework
I have encountered a problem twice now whereby a producer thread produces N work
I have encountered a problem of placing data into the Table View. Here is
I have encountered a problem in my application. I have two forms, one that
I have encountered this topic lately and couldn't understand why they are needed. Can
I have encountered a problem in my program that has me somewhat stumped. I
I have encountered a problem since one hour..take me as a beginner please.. The

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.