overload getline problem

i keep getting an error saying
error: no instance of overloaded function "getline" matches argument"
and when i take out "getline(is, purchase.price,'\t');
getline(is, purchase.quantity,'\t');" it works fine

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

struct salesTran {
string name;
string type;
string style;
double price;
double quantity;

ostream& operator << (ostream& os, salesTran purchase)
{os << purchase.name << "\t" << purchase.type << "\t" << purchase.style << "\t" << purchase.price << "\t" << purchase.quantity;
return os;}

istream& operator >> (istream& is, salesTran& purchase)
{getline(is, purchase.name,'\t');
getline(is, purchase.type,'\t');
getline(is, purchase.style,'\t');
getline(is, purchase.price,'\t');
getline(is, purchase.quantity,'\t');
return is;}

int main()
ifstream indata;
salesTran purchase[75];
int subtotal=0;

for(int x=0;x<75;x++)
for(int y=0;y<75;y++)
cout << purchase[y].name;
cout << purchase[y].type;
cout << purchase[y].style;
cout << purchase[y].price;
cout << purchase[y].quantity;

for(int z=0;z<75;z++)
cout << purchase[z]; cout << "\t" <<purchase[z].quantity*purchase[z].price << endl;

return 0;
1. Try to use code blocks when pasting/writing code in this forum. It's done with the <> button next to the window where you write posts.
2. This is not a windows programming issue. You should've posted in in the beginners or general C++ section.

To answer your question the parameter you can pass to getstring are:
istream object on which the extraction operation is performed.
string object where the extracted content is stored.
The delimiting character. The operation of extracting successive characters is stopped when this character is read.

Your members double price and double quantity are of type double. Not of type string

Hope that helps.

Last edited on
Topic archived. No new replies allowed.