Hello, all!
I'm getting an error that I don't understand, and would greatly appreciate some other input from somebody more experienced than me!
So here's the problem:
I have a tree that I can put nodes on, take nodes off, search, etc etc.
I have one last function that I canot get to work.
I need it to: 1 - traverse my tree in an inorder fashion
2 - print out the contents of each node on the tree
The unique key for each node is the 7 digit phone number
I have a struct I called Data that consists of a string name and a string address.
Here is the snippet of my program that defines the functions of my tree:
template <class KeyType, class DataType>
void BST<KeyType, DataType>::traverse(TraverseType traverseType, void (*visit)(DataType))
{
switch (traverseType)
{
case INFIX:
_traverseInfix(root, visit);
break;
case PREFIX:
_traversePrefix(root, visit);
break;
case POSTFIX:
_traversePostfix(root, visit);
break;
}
}
Here is the piece from my main program where I declare a function called printData:
template<class Data>
void printData(Data data)
{
cout << "Address is: " << data.address << " name is: "
<< data.name << endl;
}
and finally here is the piece of code where I (attempt) to implement the traversal function in my main program.
result = tree.traverse(INFIX, printData(data));
if (result)
{
cout << "Traversal was: " << result << endl;
}
else
{
cout << "Back to the old drawing board" << endl;
}
The error I get is:
Error: invalid use of void expression
Thank you in advance for your assistance.
Jim