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
}
}