error in code

hello dear i was debugging the following code it was giving following error
234 D:\Documents and Settings\Administrator\My Documents\Untitled1.cpp expected constructor, destructor, or type conversion before '*' token 234 D:\Documents and Settings\Administrator\My Documents\Untitled1.cpp expected `,' or `;' before '*' token [/b]


--------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
#define max(a,b) (((a) > (b)) ? (a) : (b))

using namespace std;
class tree
{
private:
int i;
int r;
int a[10];
struct node
{
int data;
int b;
node *left;
node *right;
node *parent;
}*p;
public:
tree();
~tree();
void create_tree(int);
void traverse();
void newbalf(node* );
int height(node*);
void inorder(node *);
void preorder(node *);
void postorder(node *);
void insert(int num);
void del(int num);
node* findimbal(node* );
void rotation(node *r);
};
tree::tree()//constructor
{ p=NULL;
}
tree::~tree()//Destructor
{

}
int main(int argc,char* argv[])
{
tree t;
t.create_tree(3);
t.create_tree(2);
t.create_tree(1);
t.create_tree(4);
t.create_tree(5);
t.create_tree(6);
t.create_tree(7);

t.traverse();

getch();
}



int tree:: height(node *temp)
{
if(temp==NULL) return 0;
else return max(height(temp->left),height(temp->right))+1;
}



void tree::create_tree(int num)
{
node *q,*temp,*parent,*n;
n=new node;
n->data=num;
n->b=0;
n->left=NULL;
n->right=NULL;
n->parent=NULL;
q=p;
if(q==NULL)//eMPTY TREE
{ p=n;
}
else
{
while(q!=NULL)
{
temp=q;
if(q->data<num)
q=q->right;
else
q=q->left;
}
if(temp->data <num)
temp->right=n;
else
temp->left=n;
n->parent=temp;

newbalf(n->parent);
temp=findimbal(n->parent);//temp var is pointing to imbal node
if(temp==NULL)
return ;
else
rotation(temp);
}
}
void tree::rotation(node *r)
{ node* A,*B,*C,*F;
A=r;

F=r->parent;
if(r->b==2)
{//left sub tree has more node
B=A->left;
if(r->left->b==+1)
{//left-left rotation
C=B->left;
A->left=B->right;
B->right=A;
if(F==NULL)
{//Root is changed
p=B;
cout<<"root is changed\n";
}
else
{
if(F->right==A)
F->right=B;
else
F->left=B;
B->parent=F;
A->parent=B;
A->left->parent=A;
}
//call update balance fator form A as B is parent
newbalf(A);
//end of left-left rotation
}

else//left right rotation
{
C=B->right;
A->left=C->right;
C->right->parent=A;
B->right=C->left;
C->left->parent=B;
C->left=B;
B->parent=C;
C->right=A;
A->parent=C;
C->parent=F;
if(F==NULL)
{
p=C;
cout<<"root is changed\n";
}
else
{
if(F->right=A)
F->right=C;
else
F->left=C;
}
newbalf(A);
newbalf(B);
//end of lr rotation
}

}//end of all left rotation
else
{//right child has more node
B=A->right;
if(r->b==-1)
{
C=B->right;
A->right=B->left;
A->right->parent=A;
B->left=A;
A->parent=B;
B->parent=F;
if(F==NULL)
{
p=B;
cout<<"root node changed\n";
}
else
{
if(F->right==A)
F->right=B;
else
F->left=B;
}
newbalf(A);
//end of right rotation
}
else
{
C=B->left;
B->left=C->right;
B->left->parent=B;
A->right=C->left;
A->right->parent=A;
C->right=B;
B->parent=C;
C->left=A;
A->parent=C;
C->parent=F;
if(F==NULL)
{
p=C;
cout<<"root changed\n";
}
else
{
if(F->right=A)
F->right=C;
else
F->left=C;
}
newbalf(A);
newbalf(B);
//end of right-left rotation
}
//end of right rotation
}
//end of function rotation
}
void tree:: newbalf(node* r)
{ //traversing back to root and filling new balance factor
while(r!=p)
{
r->b=height(r->left)-height(r->right);
r=r->parent;
}
}
node* tree :: findimbal(node *r)
{ // find node whose balfactor is -2
while(r!=p)
{
if((r->b==-2)||r->b==2)
return r;
else
r=r->parent;
}
//reached root thus tree bal
cout<<"tree is balance after insertion\n";
return NULL;
}
void tree::inorder(node *q)
{
if(q!=NULL)
{
inorder(q->left); //By recurssion
cout<<"\t "<<q->data<<flush;
inorder(q->right);//By recurssion
}

}
void tree::preorder(node *q)
{
if(q!=NULL)
{

cout<<"\t "<<q->data<<flush;
inorder(q->left); //By recurssion
inorder(q->right);//By recurssion
}


}

void tree::postorder(node *q)
{
if(q!=NULL)
{


inorder(q->left); //By recurssion
inorder(q->right);//By recurssion
cout<<"\t "<<q->data<<flush;
}


}







need help pls correct errors
Topic archived. No new replies allowed.