Thread: Can't fix compiler error

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    6

    Can't fix compiler error

    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;
    };


    &#91;code]&#91;/code]tagged by Salem

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    tree is a pointer. You use the -> operator not the .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM