| | |
List.Sort(compare_function) - term does not evaluate to a function taking 2 arguments
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2006
Posts: 35
Reputation:
Solved Threads: 0
List.Sort(compare_function) - term does not evaluate to a function taking 2 arguments
0
#1 Jul 15th, 2009
I am trying to customize my sorting of a LIST using a compare_function, but for some odd reason it keeps giving me the following error:
error C2064: term does not evaluate to a function taking 2 arguments
Specifically, I have list created within class B which needs to be sorted, the list contains elements of type A* as shown below:
Class B code:
Just for completness the following is the code for Class A:
So, pretty much I just want to sort AList by ID, but for some odd reason this generates:
error C2064: term does not evaluate to a function taking 2 arguments
Also, in the future I am going to want to create a compareCode() function to also compare by code ... thought if one way works so will the other ...
Any clues, hints, or help would be greatly appreciated.
Thanks,
error C2064: term does not evaluate to a function taking 2 arguments
Specifically, I have list created within class B which needs to be sorted, the list contains elements of type A* as shown below:
Class B code:
C++ Syntax (Toggle Plain Text)
B::B() { list<A*> AList; AList.push_back(new A(ID_1, CODE_1)); AList.push_back(new A(ID_2, CODE_2)); AtList.sort(&B::compareID); } bool B::compareID(A* first, A* second) { return true; // test for now }
Just for completness the following is the code for Class A:
C++ Syntax (Toggle Plain Text)
Class A { long ID; string sCode; A(_ID, _sCode) : ID(_ID), sCode(_sCode) {}; }
So, pretty much I just want to sort AList by ID, but for some odd reason this generates:
error C2064: term does not evaluate to a function taking 2 arguments
Also, in the future I am going to want to create a compareCode() function to also compare by code ... thought if one way works so will the other ...
Any clues, hints, or help would be greatly appreciated.
Thanks,
Re: List.Sort(compare_function) - term does not evaluate to a function taking 2 arguments
0
#2 Jul 15th, 2009
Is this the exact code you compiled? And is that the only error you got? Your code has a lot of other compiler errors too as of now. It'll be good if you paste the entire code after you remove all the errors that you can and then we'll be able to help you better with the one's remaining.
thanks
-chandra
-chandra
Re: List.Sort(compare_function) - term does not evaluate to a function taking 2 arguments
0
#3 Jul 15th, 2009
•
•
Join Date: Dec 2007
Posts: 360
Reputation:
Solved Threads: 69
Re: List.Sort(compare_function) - term does not evaluate to a function taking 2 arguments
0
#4 Jul 15th, 2009
Why is compareId() a member of B
This does work:
This does work:
C++ Syntax (Toggle Plain Text)
#include <string> #include <list> using namespace std; struct A { long ID; string sCode; A(long ID_, string const & sCode_) : ID(ID_), sCode(sCode_) {} }; bool compareID(A* first, A* second) { return true; // test for now } class B { B() { list<A*> AList; AList.push_back(new A(1, "one")); AList.push_back(new A(2, "two")); AList.sort(compareID); } };
If you are forced to reinvent the wheel at least try to invent a better one!
Please use code tags - Please mark solved threads as solved
Please use code tags - Please mark solved threads as solved
![]() |
Similar Threads
- error C2064: term does not evaluate to a function taking 1 arguments (C++)
- error C2064: term does not evaluate to a function taking 1 arguments line 33 (C++)
- Function headers, arguments and storing results to arrays (C++)
- Error: term does not evaluate to a function taking 1 arguments (C++)
- Term does not evaluate to a function (C++)
- error C2064: term does not evaluate to a function taking 1 arguments (C++)
Other Threads in the C++ Forum
- Previous Thread: How to get local disk used space
- Next Thread: please help to convert from c to c++ just??
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector visualstudio win32 windows winsock word wordfrequency wxwidgets






