Error with std::sort

closed account (EwCjE3v7)
Have no idea why i get this error, with a lambda i get no errors but I need to use a function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
bool compareIsbn(const Sales_data &book1, const Sales_data &book2)
{
	return atoi(book1.isbn().c_str()) < atoi(book2.isbn().c_str());
}

int main()
{	
	vector<Sales_data> items;
	Sales_data item;

	while (read(cin, item)) 
		items.push_back(item);

	sort(items.begin(), items.end(), compareIsbn);


	return 0;
}


ISBN class:
http://pastebin.com/c9vjWmHh

Error:
Testing.cpp: In function ‘int main()’:
Testing.cpp:40:46: error: no matching function for call to ‘sort(std::vector<Sales_data>::iterator, std::vector<Sales_data>::iterator, <unresolved overloaded function type>)’
  sort(items.begin(), items.end(), compareIsbn);
                                              ^
Testing.cpp:40:46: note: candidates are:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from Testing.cpp:12:
/usr/include/c++/4.8/bits/stl_algo.h:5474:5: note: template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^
/usr/include/c++/4.8/bits/stl_algo.h:5474:5: note:   template argument deduction/substitution failed:
Testing.cpp:40:46: note:   couldn't deduce template parameter ‘_Compare’
  sort(items.begin(), items.end(), compareIsbn);
                                              ^
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from Testing.cpp:12:
/usr/include/c++/4.8/bits/stl_algo.h:5438:5: note: template<class _RAIter> void std::sort(_RAIter, _RAIter)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
     ^
/usr/include/c++/4.8/bits/stl_algo.h:5438:5: note:   template argument deduction/substitution failed:
Testing.cpp:40:46: note:   candidate expects 2 arguments, 3 provided
  sort(items.begin(), items.end(), compareIsbn);
        
^
"<unresolved overloaded function type>" means you have more than one function named compareIsbn that's visible at that point in the program.
closed account (EwCjE3v7)
Oh yes, found out why, I had included Sales_item, which I hadn`t written, it was from my book and that had the exact same function as the one they told me to write. Thanks
Topic archived. No new replies allowed.