내 벡터에서 '2'를 제거하기 위해이 지우기 기능을 실행하려고 할 때 오류 목록이 발생했습니다. 나는 문제가 어디 있는지 모르겠습니다. 도움말 크게 감사드립니다!벡터의 특정 값 제거
구조체 민트
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
{
std::vector<MyInt> values;
MyStuff() : values()
{ }
};
주요 구조체 mystuff에
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;
}
오류 메시지
,691,363,210stl_algo.h : 기능의 '_OutputIterator의 표준 : remove_copy (_InputInputIterator, _InputIterator, const_Tp &) with_InputIterator = __gnu_cxx : normal_iterator __>> OutputIterator = __ __ gnu_cxx :: 정상 반복자>> Tp를 = INT]
연산자 == '에 대한 검색은
Erorr 메시지는 partciular 라인 stl_algo.h의 라인 실질적 라인 1,267, 1,190, 327, 1,263, 208, 212, 216, 220, 228, 232을 위반했다 , 236
"어떤 경기를 운영자 =="무엇 그것에 대해 불분명? myInt와 정수를 비교할 수 있도록'operator =='함수를 정의해야합니다. – jrok
@jrok, 답변이어야합니다. 정말 간단합니다. – chris