c++ - error: cannot convert in arguement passing -


i have code this:

template <class item,class key> class bst {  public:   //bst(const item& new_item,const key& new_key);    key get_key() const {return key;};   item get_item() const {return item;};   bst get_right() const {return *rightptr;};   bst get_left() const {return *leftptr;};    void set_key(const key& new_key) {key = new_key;};   void set_item(const item& new_item) {item = new_item;};   void set_right(bst *new_right) {rightptr=new_right;};   void set_left(bst *new_left) {leftptr=new_left;};    item item;   key key;   bst *rightptr;   bst *leftptr;  private: };   template <class item,class key,class process,class param> void inorder_processing_param(bst<item,key> *root,process f,param p) {   if(root==null)     {return;}   else     {       inorder_processing(root->leftptr,f,p);       f(root->item,p);       inorder_processing(root->rightptr,f,p);     } }  void perfect(studentrecord s) { if (s.gpa==4.0)   {     cout << s.id << "  " << s.student_name;   } }  void major_m(bst<studentrecord,int>* root) { if (root->item.major=="m")   {     cout << root->item.id << "  " << root->item.student_name;   } }  void print_major(bst<studentrecord,int>* root,char* m) {     inorder_processing(root,major_m); } 

it make error when run it:

bst.template: in function `void inorder_processing(bst<item, key>*, process)     [with item = studentrecord, key = int, process = void (*)(bst<studentrecord,     int>*)]': studentdatabase.cxx:97:   instantiated here bst.template:151: error: cannot convert `studentrecord' `bst<studentrecord,     int>*' in argument passing 

how fix it

change:

f(root->item,p); 

to:

f(root); 

alternatively, add param major_m , call f(root, p)

edit: apparently you've not posted

template <class item,class key,class process,class param> void inorder_processing(bst<item,key> *root,process f) 

function. given code have, i'll make guess call f(root->item) in - when need f(root)


Comments