Jump to content
Xtreme .Net Talk

List.Sort(compare_function) - term does not evaluate to a function taking 2 arguments


Recommended Posts

Posted

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:


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
}
[/Code]

 

Just for completness the following is the code for Class A:

[Code]
Class A
{
long ID;
string sCode;
A(_ID, _sCode) : ID(_ID), sCode(_sCode) {};
}
[/Code]

 

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,

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...