Newsgroup: it.comp.lang.c++
Titolo: question about passing a function pointer in visual c++

Sorry to bother everone again but now I am having trouble printing out the
data in the nodes in my binary search tree.  Here is the error i am getting.
In an earlier post I didn't frase the question properly and had too much
irrelevent code, if I am making the same mistakes I am sorry and please
don't hesitate to bring them to my attention.  Thanks in advance for any
hints or suggestions.
Compiling...
test.cpp
C:\Documents and Settings\TJ\Desktop\Programming\test.cpp(312) : error
C2228: left of '.DisplayNfo' must have class/struct/union type
        C:\Documents and Settings\TJ\Desktop\Programming\test.cpp(303) : see
reference to function template instantiation 'void __cdecl PrintData(class
Customer *& )' being compiled
Error executing cl.exe.
test.obj - 1 error(s), 0 warning(s)
here are some relevant parts of my source code.
class Customer
{
public:
 Customer(char n[50], char add[50], int z, int social, double bal);
 void DisplayNfo(); //displays customer information
private:
 char name[50];
 char address[50];
 int zip;
 int ssn;
 double balance;
};
//definition of DisplayNfo
void Customer::DisplayNfo()
{
 cout<<"\n"<<name<<"\n";
 cout<<address<<"\n";
 cout<<zip<<"\n";
 cout<<ssn<<"\n";
 cout<<balance<<"\n\n\n";
}
//-----------------------Node------------------------
template <class Entry>
struct Binary_node {
//    data members:
   Entry data;
   Binary_node<Entry> *left;
   Binary_node<Entry> *right;
//    constructors:
   Binary_node();
   Binary_node(const Entry &x);
};
template <class Entry>
Binary_node<Entry>::Binary_node(const Entry &x)
{
 data=x;
 left=NULL;
 right=NULL;
}
//----------------------------BT code------------------------
template <class Entry>
class Binary_tree {
public:
   Binary_tree();
   bool empty() const;
   void inorder(void (*visit)(Entry &));
   void A(void (*visit)(Entry &));
   void insert(const Entry &);
   Binary_tree (const Binary_tree<Entry> &original);
   Binary_tree & operator =(const Binary_tree<Entry> &original);
   //~Binary_tree();
protected:
   Binary_node<Entry> *root;
   void recursive_inorder(Binary_node<Entry> *sub_root,void (*visit)(Entry
&));
};
template <class Entry>
void Binary_tree<Entry>::inorder(void (*visit)(Entry &))
/*
Post: The tree has been traversed in inorder sequence.
Uses: The function recursive_inorder
*/
{
   recursive_inorder(root, visit);
}
template <class Entry>
void Binary_tree<Entry>::recursive_inorder(Binary_node<Entry> *sub_root,
                                           void (*visit)(Entry &))
/*
Pre:  sub_root is either NULL or points to a subtree of the Binary_tree.
Post: The subtree has been traversed in inorder sequence.
Uses: The function recursive_inorder recursively
*/
{
   if (sub_root != NULL) {
      recursive_inorder(sub_root->left, visit);
      (*visit)(sub_root->data);
      recursive_inorder(sub_root->right, visit);
   }
}
template <class Record>
class Search_tree: public Binary_tree<Record> {
public:
private:
};
template <class Entry>
void PrintData(Entry &x);
int main()
{
 Search_tree<Customer*> t1;
 Customer *p;
 p=new Customer("Jim","Sinkansen",333,5,20.00);
 t1.insert(p);
 p=new Customer("tj","Sinkansen",333,3,20.00);
 t1.insert(p);
-------------------------------I think this is where my problem begins but I
am not entirely sure-------------------------------------
 t1.inorder(PrintData);
 return 0;
}
template <class Entry>
void PrintData(Entry &x)
{
 x.DisplayNfo();
}

Hi,
You may not be aware that you posted your message on the italian C++
newsgroup (the "it" in the group's name stands for "Italy").
You may have better luck with one of the following:
comp.lang.c++
comp.lang.c++.moderated
Best regards,
Nicola Musatti
-- 
Posted via Mailgate.ORG Server - 
http://www.Mailgate.ORG