can't seem to fix this compiler error.......any help is 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(425) : error C2228: left of '.IsEmpty' must have class/struct/union type
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(416) : see reference to function template instantiation 'void __cdecl PrintValue(struct TreeNode<int> *,int)' being compiled
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(429) : error C2228: left of '.ResetTree' must have class/struct/union type
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(416) : see reference to function template instantiation 'void __cdecl PrintValue(struct TreeNode<int> *,int)' being compiled
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(434) : error C2228: left of '.GetNextItem' must have class/struct/union type
c:\program files\microsoft visual studio\myprojects\binary search tree adt\tree.h(416) : see reference to function template instantiation 'void __cdecl PrintValue(struct TreeNode<int> *,int)' being compiled
Error executing cl.exe.
Binary Search Tree ADT.exe - 3 error(s), 0 warning(s)
Code:
template<class ItemType>
void PrintValue(TreeNode<ItemType>*, ItemType);
//prototype function
template<class ItemType>
void TreeType<ItemType>::PrintValuesOfTree(ItemType value) const
//Pre: tree has been initialized
//Post: prints the nodes ni the tree that are less than value
{
PrintValue(root, value);
}
template<class ItemType>
void PrintValue(TreeNode<ItemType>* tree, ItemType value)
{
ItemType item;
bool finished = false;
if(tree.IsEmpty())
cout << "tree is empty" << endl;
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;
}
}
}
*********HERE"S the CLASS specs********************
template<class ItemType>
struct TreeNode;
// Assumption: ItemType is a type for which the operators <
// and == are defined either an appropriate built-in type or
// a class that overloads these operators.
enum OrderType {PRE_ORDER, IN_ORDER, POST_ORDER};
template<class ItemType>
class TreeType
{
public:
TreeType(); // constructor
~TreeType(); // destructor
TreeType(const TreeType<ItemType>& originalTree);
// copy constructor
void operator= (const TreeType<ItemType>& originalTree);
void MakeEmpty();
bool IsEmpty() const; // not implemented
bool IsFull() const; // not implemented
int NumberOfNodes() const;
void RetrieveItem(ItemType& item, bool& found);
void InsertItem(ItemType item);
void DeleteItem(ItemType item);
void ResetTree(OrderType order);
void GetNextItem (ItemType& item, OrderType order,
bool& finished);
void PrintTree(std::ofstream& outFile) const;
void Ancestors(ItemType value) const;
void PrintValuesOfTree(ItemType value) const;
int MaxSubTree(ItemType value);
int MinSubTree(ItemType value);
private:
TreeNode<ItemType>* root;
QueType<ItemType> preQue;
QueType<ItemType> inQue;
QueType<ItemType> postQue;
};
template<class ItemType>
struct TreeNode
{
ItemType info;
TreeNode* left;
TreeNode* right;
};
[code][/code]tagged by Salem