// error: expected constructor, destructor, or type conversion before '*' token
*** Error code 1
make: Fatal error: Command failed for target `bst.o'

class BinarySearchTree
{
        private:
        int count;
		int n;
        struct tree_node
			{
			   tree_node* left;
			   tree_node* right;
			   char data[1000];
			   
			};
        tree_node* root;

        public:
			BinarySearchTree()
			{
			   root = NULL;
				count = 0;
				 n=1;
			 
			}
        
		bool isEmpty() const { return root==NULL; }
		void print_preorder();
		void print_format(tree_node*,int,int[100],char) const;
		void preorder(tree_node*,int,int[100],char) const;
		void insert(char*);
		void remove(char*);
		bool search(char*);
		tree_node* inorderSuccessor(tree_node*); /* Finds the inorder successor of a node */
		int num_nodes();
		//int countNodes(tree_node *&root);
  
};



tree_node* BinarySearchTree::inorderSuccessor(tree_node* p )
	{
  
   if(!p) return NULL;
   p=p->right;
    if (!p) return NULL;
 
    while (p->left) {
        p= p->left;
    }
    return p;
}

Which line?

Line 40

Line 40

Since tree_node is nested inside the BinarySearchTree class, you need to apply the scope resolution operator ..

[B]BinarySearchTree[/B]::tree_node * BinarySearchTree::inorderSuccessor(tree_node* p ){}

or make the declaration of tree_node public and use a typedef ..

typedef BinarySearchTree::tree_node treeNode;
treeNode * BinarySearchTree::inorderSuccessor2(tree_node* p ){}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.