7 Replies - 7003 Views - Last Post: 25 October 2010 - 01:35 AM Rate Topic: -----

#1 Cloudyeyes   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-May 10

C3867: Function call missing argument list / overloaded function

Posted 24 October 2010 - 06:22 PM

In void getdata for each cout:
-'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;
}



Is This A Good Question/Topic? 0
  • +

Replies To: C3867: Function call missing argument list / overloaded function

#2 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3872
  • View blog
  • Posts: 14,211
  • Joined: 08-August 08

Re: C3867: Function call missing argument list / overloaded function

Posted 24 October 2010 - 06:31 PM

What is this doing?
		r.getdata(r);


Is it your intention to pass an object to itself by reference?
Why can't you just do:
r.getdata();
and let getdata grab its own variables?

Edit:
Your cout() function does this, but then you try to call it with a parameter:
        r.cout(r);


This post has been edited by CTphpnwb: 24 October 2010 - 06:32 PM

Was This Post Helpful? 0
  • +
  • -

#3 Cloudyeyes   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-May 10

Re: C3867: Function call missing argument list / overloaded function

Posted 24 October 2010 - 06:43 PM

View PostCTphpnwb, on 24 October 2010 - 05:31 PM, said:

What is this doing?
		r.getdata(r);


Is it your intention to pass an object to itself by reference?
Why can't you just do:
r.getdata();
and let getdata grab its own variables?

Edit:
Your cout() function does this, but then you try to call it with a parameter:
        r.cout(r);



Hi, the reason why I'm including an argument is because Visual Studio tells me that the r.getdata function cannot take 0 arguments, so I just put in an r... the argument in the r.cout function was a bit of a typo. I just deleted it and I'm getting the same errors.

oooh! I just realized what I was doing wrong. I was naming a function "cout" and visual studio was getting that confused with the usual cout. So, every time I typed cout, it would get both the function cout and cout mixed up.
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3872
  • View blog
  • Posts: 14,211
  • Joined: 08-August 08

Re: C3867: Function call missing argument list / overloaded function

Posted 24 October 2010 - 06:43 PM

You need to talk to the person who wrote the getdata function.
Was This Post Helpful? 0
  • +
  • -

#5 Cloudyeyes   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-May 10

Re: C3867: Function call missing argument list / overloaded function

Posted 24 October 2010 - 06:44 PM

Now the whole thing works :)
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3872
  • View blog
  • Posts: 14,211
  • Joined: 08-August 08

Re: C3867: Function call missing argument list / overloaded function

Posted 24 October 2010 - 06:47 PM

It can work and still be wrong.
Was This Post Helpful? 0
  • +
  • -

#7 Cloudyeyes   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-May 10

Re: C3867: Function call missing argument list / overloaded function

Posted 24 October 2010 - 07:01 PM

View PostCTphpnwb, on 24 October 2010 - 05:47 PM, said:

It can work and still be wrong.


Right, cause my searching algorithm's all screwed up. What I'm trying to do is have the user input a customer ID. What the program does is searches for the customer ID in the text file, then grabs every value from that text line temporarily into data.
Was This Post Helpful? 0
  • +
  • -

#8 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: C3867: Function call missing argument list / overloaded function

Posted 25 October 2010 - 01:35 AM

So how are you going with this?
All fixed or are you still having trouble?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1