no matches converting function `concat' to type `class Dlist (*)(class List<int>, class List<int>)'
error candidates are: template<class T> Dlist concat(Dlist, Dlist)
no matching function for call to `concat(Dlist&, Dlist&)'
I can't understand what the compiler is trying to tell me. Can somebody help me please?
To begin with, there is no way for the compiler to deduce the type of T you intend to use for the template function concat (and, indeed, one wonders why you're making it a template function.)
I might expect concat to look more like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
template <typename T>
T concat( T a, T b)
{
// since a and b are copies of lists, we can just append b to a and return a.
auto node = b.Start_ptr ;
while ( node )
{
a.Add_node(node->data) ;
node = node->next ;
}
return a ;
}
and then the call becomes: Dlist L = accumulate(concat<Dlist>, New, A);
[edit: This all assuming you have supplied an appropriate copy constructor and copy assignment operator, of course.]