Can someone please help me with this compiler error........any help would be much appreciated
Thanks
Deleting intermediate files and output files for project 'Binary Search Tree ADT - Win32 Debug'.
--------------------Configuration: Binary Search Tree ADT - Win32 Debug--------------------
Compiling...
tree.cpp
treetester.cpp
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(377) : error C2270: 'PrintAncestors' : modifiers not allowed on nonmember functions
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(398) : error C2270: 'PrintAncestors' : modifiers not allowed on nonmember functions
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(402) : error C2270: 'PrintValue' : modifiers not allowed on nonmember functions
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(438) : error C2270: 'PrintValue' : modifiers not allowed on nonmember functions
Error executing cl.exe.
Binary Search Tree ADT.exe - 4 error(s), 0 warning(s)
******************************
*****************************
*******HERE'S THE CODE*********
template<class ItemType>
void PrintAncestors(TreeNode<ItemType>* tree, ItemType value) const;
//prototype
template<class ItemType>
void TreeType<ItemType>::Ancestors(ItemType value) const
//calss recursive function PrintAncestors to print the ancestors
{
PrintAncestors(root, value);
}
template<class ItemType>
void PrintAncestors(TreeNode<ItemType>* tree, ItemType value) const
{
if(tree->info != value)
{
cout << tree->info << endl;
if(tree->info < value)
PrintAncestors(tree->right, value);
else
PrintAncestors(tree->left, value);
}
}
template<class ItemType>
void PrintValue(TreeType<ItemType> tree, ItemType value) const;
//prototype
template<class ItemType>
void TreeType<ItemType>::PrintValuesOfTree(ItemType value) const
//calls function PrintValue to print values of tree less than value
{
PrintValue(tree, value);
}
template<class ItemType>
void PrintValue(TreeType<ItemType> tree, ItemType value) const
//Pre: tree has been initialized
//Post: Prints values in tree that contain values that are less than value
{
ItemType item;
bool finished = false;
if(tree.IsEmpty())
return 0;
else
{
tree.ResetTree(IN_ORDER);
//process stops when larger value is reached
while(!finished)
{
tree.GetNextItem(item,finished, IN_ORDER);
if(item < value)
cout << item << endl;
else
finished = true;
}
}
}