Hello to every body
I hope every one keep in best state.
I want to help me in solve this problem in my Sheet .
I use recurrence functions in like list.( with ADT file ) by modify the search function and adding Printing function in a Reverse Manner.
template <class TYPE, class KTYPE>
bool List<TYPE, KTYPE> :: _search (NODE<TYPE> **pPre,
NODE<TYPE> **pLoc,
KTYPE key)
{
if ((*pLoc) == NULL)
return false;
else
if (key == (*pLoc)->data.key)
return true;
_search ((*pPre)->link ,(*pLoc)->link, key);
return false;
}
template bool List :: _search (NODE **pPre, NODE *pLoc, KTYPE key) { if ((pLoc) == NULL) return false; else if (key == (*pLoc)->data.key) return true; search ((pPre)->link ,(*pLoc)->link, key); return false; }
put taken error in
_search ((*pPre)->link ,(*pLoc)->link, key);
I don't Know why? I tru to put or delete * put not any answer
the error:
error C2664: 'List<TYPE,KTYPE>::_search' : cannot convert parameter 1 from 'NODE<TYPE> *' to 'NODE<TYPE> **'
and I initialize it : Help with Code Tags (Toggle Plain Text)
NODE * pPre; pPre = NULL; NODE * pLoc ; pLoc = NULL;
NODE * pPre; pPre = NULL; NODE * pLoc ; pLoc = NULL; befor the function calling
this function return the location of pPre and pLoc in memory , so must the function signature keep of **. So , must to change the way you are calling it. but how ?
Help with Code Tags (Toggle Plain Text)
template <class TYPE>
struct NODE
{
TYPE data;
NODE *link;
};
struct Student
{
string name ;
int level;
int key;
};
template <class TYPE, class KTYPE>
class List
{
private:
NODE<TYPE> *head;
NODE<TYPE> *pos;
NODE<TYPE> *rear;
int count;
....
....
....
....
....
};
template struct NODE { TYPE data; NODE *link; }; struct Student { string name ; int level; int key; }; template class List { private: NODE *head; NODE *pos; NODE *rear; int count; .... .... .... .... .... };
and the print Function
ostream & operator << (ostream & out , Student & Data)
{
out << "The name is : " << Data.name << "\nThe Level is : " << Data.level<< "\nThe ID is :"<<Data.key;
return out;
}
template<class TYPE, class KTYPE>
void List <TYPE, KTYPE > :: ReversePrint ( NODE <TYPE> * node )
{
if ( node== NULL)
return ;
ReversePrint (node->link);
cout << node-> data;
return ;
}
thank you to help me