I want to write a code for recording inventory item, all the functions work fine except the function for removing the data. I spend a lot of time in it but still cannot know what's wrong. Here is my code:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;

class InventoryInfo  {
	string ID, Name;

public:
	InventoryInfo()	{ ID = ""; Name = "";}
	InventoryInfo(string ItemID, string ItemName) {ID = ItemID; Name = ItemName;}

	void setItemID(string ItemID) {ID = ItemID;}
	void setItemName(string ItemName)   {Name  = ItemName;}

	string getItemID() { return ID;}
	string getItemName()  { return Name;}

	void Display();
};
void InventoryInfo::Display()
{
	cout << ID << " " << Name << endl;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class FileDoItAll {
	string FileName;
	vector<InventoryInfo> List;
	vector<InventoryInfo>::iterator IteratorList;

public:
	FileDoItAll() {;}
	FileDoItAll(string FName) {FileName = FName;}

	void AddList();
	void ViewList();
	void RemoveList();
	void SetFileName(string FName) { FileName = FName;}
    void WriteFile();
    void ReadFile();
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void FileDoItAll::RemoveList()
{
	string ItemRemove;
	
	cout << "Enter the ID of item want to be removed: ";
	getline(cin, ItemRemove);

	for(IteratorList = List.begin() ; IteratorList != List.end() ; IteratorList++) {
		if(*IteratorList == ItemRemove)  {
				List.erase(IteratorList);  //Remove the current object..
				return;  //Time to leave the loop...and the function...
		  } 
	}
     cout << ItemRemove << " ID is not found!!" << endl;
}

///////////////////////////////////////////////////////////////////
Here is the error:

Final.cpp
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string(91) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const _Elem *' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string(81) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string(71) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(1259) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not deduce template argument for 'const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\iterator(266) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\xmemory(174) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\xutility(2143) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\xutility(1826) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'InventoryInfo'
C:\Program Files\Microsoft Visual Studio 8\VC\include\utility(60) : see declaration of 'std::operator =='
.\Final.cpp(83) : error C2676: binary '==' : 'InventoryInfo' does not define this operator or a conversion to a type acceptable to the predefined operator

>>.\Final.cpp(83) :
So why didn't you post the code that's in Final.cpp ?

line 56 of the code you posted: ItemRemove is a std::string while *IteratorList is not, so the comparison is illegal, unless you wrote an == operator, which you did not do.

This article has been dead for over six months. Start a new discussion instead.