Original Post
Hi people,
I have a slight problem an having trouble to understand why it's causing a compile error.
I have a slight problem an having trouble to understand why it's causing a compile error.
error C2664: 'Lex::LinkedList::setSortQuery' : cannot convert parameter 1 from 'Lex::LinkedList ::SortReturnCode (__cdecl *)(const Data,const Data)' to 'Lex::LinkedList ::SortReturnCode (__cdecl *)(const T,const T)'
with
[
T=Data *
]
None of the functions with this name in scope match the target type[/quote]
Here is a code snippet
template<class T>
class LinkedList
{
public:
enum SortReturnCode{LOWEST=1, HIGHEST=2, IDENTICAL=4};
typedef SortReturnCode (*SortQueryFncPtr)(const T Data1, const T Data2);
void setSortQuery(SortQueryFncPtr pSortQueryFncPtr)
{
m_pSortQueryFncPtr = pSortQueryFncPtr;
}
private:
SortQueryFncPtr m_pSortQueryFncPtr;
};
struct Data
{
char cTest[255];
};
static LinkedList<Data*>::SortReturnCode SortTest(const Data *Test1, const Data *Test2)
{
return LinkedList<Data*>::IDENTICAL;
}
int main()
{
LinkedList<Data*> listTest;
listTest.setSortQuery(SortTest);
return 0;
}
If I create a list container that contains a non-pointer value, (T=Data), then there is no error. Could anyone be kind to explain why I retrieve this error.
thanks