When i tried to compile it, it gave me this error "no match for operator". Any idea how could this happen? This program will take user input and add it into dat file

#define CONTACTS "contacts.dat"
#include <iostream> //enable the used of cin and cout 
#include <fstream>  //enable writing file and reading file, ofsream and ifstream
#include <cstdlib> //enable for exit() function
#include <vector>  //enable function of vector array 
#include <ctype.h>


using namespace std;

class Contact{
	private: 
	int phones;
	string email;
	string name;
	
	public:
	void setname(string name);
	string takename();
	void setphone(int numbers);
	int takephone();
	void setemail(string mail);
	string takeemail();
	
};

int i =0;
void Contact::setname(string name)
{
  ofstream myfile;
  myfile.open(CONTACTS);
  if (myfile.is_open());
  {
  myfile<<name<<endl;
  myfile.close();
  }
  
  
}
int main(int argc, char* argv[])
{
	vector <string> input;
	Contact addingname;
	
if (argc == 2)
{
	input.push_back(argv[1]);
	cout<<"Ok, contact "<<" "<<i+1<<input.at(i)<<" added "<<endl;
	
	int size = input.size();
	for(int j = 0; j<size; j++)
	{
		if(input[i] == '@') //error in this section, no match for operator?
			
		{
			cout<<"with email address"<<endl;
		
		}
		else
			{
			i++;
			}
		
	}
	
}

	for(int j=0;j<int(input.size());j++)
	{
	
		addingname.setname(input.at(j));
		input.erase(input.begin(),j); //and error in this section as well?a long error
	}
}

Edited 6 Years Ago by Bigbrain99: n/a

You haven't given a specific Line number for us to look at, but I'm guessing the error points to a line where you use an std::string.

You have not included the standard header <string> all of the functions and operators related to the std::string class are defined in that header. Without it, you can't do much with one.

Edited 6 Years Ago by Fbody: n/a

int size = input.size();
#
for(int j = 0; j<size; j++)
#
{
#
if(input[i] == '@') //error in this section, no match for operator?
#

I meant for this if section, why it will give me "no match for operator" any idea?

Edited 6 Years Ago by Bigbrain99: n/a

yup that solve my problem, and i got another error

for(int j=0;j<int(input.size());j++)
	{
	
		addingname.setname(input.at(j));
		input.erase(input.begin(),j);//error in here

it gave me an error 'no matching for function call std::........' need help again..

Edited 6 Years Ago by Bigbrain99: n/a

If you are trying to erase all contents from the beginning of input until the index
j, then do this:

input.erase(input.begin(), input.begin() + j)
This question has already been answered. Start a new discussion instead.