generate_n function error

Hi guys
I get an error when I run the following code.
I removed the generate_n function.
code working.

Where am I doing wrong.

thanks in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Record{
int count;
int price;
public:
Record(int price, int count = 0)
{
price = price;
count++;
}

friend bool operator >(const Record &r1, const Record &r2);
friend ostream &operator<<(ostream &os,  const Record &r);
		
};
bool operator >(const Record &r1, const Record &r2)
{
          if (r1.price > r2.price)
	  eturn true;
	else
	  return false;

}

ostream &operator<<(ostream &os,  const Record &r)
{

  return os << "(" << r.price << ")" << endl;
}
	

	


	
bool mypred(Record &r1, Record &r2)
{
	if (r1 > r2)
	   return true;
           return false;
}

int main()
{


	vector<Record> rvec;

	rvec.push_back(Record(45));
	rvec.push_back(Record(12));
	rvec.push_back(Record(54));
	rvec.push_back(Record(90));
	rvec.push_back(Record(43));
	rvec.push_back(Record(112));


	generate_n(rvec.begin(), rvec.end(), ostream_iterator<Record>(cout, " ")); // error

	sort(rvec.begin(), rvec.end(), mypred);

	return 0;
}

Last edited on
Topic archived. No new replies allowed.