-'record::cout':function call missing argument list; use '&record::cout' to create a pointer to member
-'<<': illegal, left operand has type 'void (_thiscall record::*)(void)'
-'<<': illegal, right operand has type char[...]
In each line in void cout:
Basically about 7 or 10 errors for each line, consisting of "overloaded function" or something.
error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'overloaded-function'
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class record
{
private:
string customerid,
companyname,
contacttitle,
address,
city,
region,
postalcode,
country,
phone,
fax;
public:
fstream file;
record(){
customerid = "null";
companyname = "null";
contacttitle = "null";
address = "null";
city = "null";
region = "null";
postalcode = "null";
country = "null";
phone = "null";
fax = "null";
}
void Copy(record & r) // copy account object
{
this ->customerid=r.customerid;
this ->contacttitle=r.contacttitle;
this ->address=r.address;
this ->city=r.city;
this ->region=r.region;
this ->postalcode=r.postalcode;
this ->country=r.country;
this ->phone=r.phone;
this ->fax=r.fax;
}
void getdata(record & r)
{
cout << "Customer ID: " << endl;
cin>> r.customerid;
cout << "Name: ";
cin>> r.companyname;
cout<< "Contact Title: ";
cin>> r.contacttitle;
cout<<"Address: ";
cin>> r.address;
cout<<"City: ";
cin>> r.city;
cout<<"Region: ";
cin>> r.region;
cout<<"Postalcode: ";
cin>> r.postalcode;
cout<<"Country: ";
cin>> r.country;
cout<<"Phone: ";
cin>> r.phone;
cout<<"Fax: ";
cin>> r.fax;
}
void cout()
{
cout<< customerid << endl;
cout<< companyname << endl;
cout<< contacttitle << endl;
cout<< address << endl;
cout<< city << endl;
cout<< region << endl;
cout<< postalcode << endl;
cout<< country << endl;
cout<< phone << endl;
cout<< fax << endl;
}
bool appendfile()
{
char Tab='\t';
if(!file)
{ cout << "Can't open output file"<<endl; return false;}
else
{
file<<customerid<<Tab
<<companyname<<Tab
<<contacttitle<<Tab
<<address<<Tab
<<city<<Tab
<<region<<Tab
<<postalcode<<Tab
<<country<<Tab
<<phone<<Tab
<<fax<<endl;
return true;
}
}
bool writefile(string id, int pposition)
{
char Tab='\t';
if(!file)
{ cout << "Can't open output file"<<endl; return false;}
else
{
while(!file.eof())
{
getline(file, customerid);
if ((pposition = customerid.find(id, 0)) != string::npos)
{
file<<customerid<<Tab
<<companyname<<Tab
<<contacttitle<<Tab
<<address<<Tab
<<city<<Tab
<<region<<Tab
<<postalcode<<Tab
<<country<<Tab
<<phone<<Tab
<<fax<<endl;
return true;
}
}
}
}
bool readline(string id, int pposition)
{
if(!file)
{ cout << "Can't open input file"<<endl; return false;}
else
{
while(!file.eof())
{
getline(file, customerid);
if ((pposition = customerid.find(id, 0)) != string::npos)
{
file>>customerid
>>companyname
>>contacttitle
>>address
>>city
>>region
>>postalcode
>>country
>>phone
>>fax;
return true;
}
}
}
}
};
int main()
{
record r;
r.file.open ("record.txt",ios::app | ios::in | ios::out);
int choice=0, pposition;
string id;
while(choice != 4){
cout<<"Menu:"<<endl;
cout<<"1. Create Record"<<endl;
cout<<"2. Modify Record"<<endl;
cout<<"3. Read Record"<<endl;
cout<<"4. Exit"<<endl;
cout<<"Please pick an item..."<<endl;
cin>>choice;
if(choice==1)
{
r.getdata(r);
r.appendfile();
}
else if(choice==2)
{
cout<<"Which customer ID would you like to modify?"<<endl;
cin>>id;
r.getdata(r);
r.writefile(id, pposition);
}
else if(choice==3)
{
cout<<"Which customer ID would you like to read?"<<endl;
cin>>id;
r.readline(id, pposition);
r.cout(r);
}
}
r.file.close();
return 0;
}

New Topic/Question
Reply



MultiQuote





|