getting error ld return 1 exit

#include<iostream>
#include<conio.h>
#include<process.h>
using namespace std;
struct tree_node
{

tree_node *left;
tree_node *right;
int data;
};
class bst
{

tree_node*root;
public:
bst()
{
root=NULL;

}
int isempty()
{
return(root==NULL);
}
void insrt(int item);
void inordertrav();
void inorder(tree_node *);
void postordertrav();
void podtorder(tree_node *);
void preordertrav();
void preorder(tree_node *);
};
void bst::insrt(int item)
{
tree_node *p=new tree_node;
tree_node *parent;
p->data=item;
p->left=NULL;
p->right=NULL;
if(isempty())
{
root=p;
}
else
{
tree_node *ptr;
ptr=root;
while(ptr!=NULL)
{

parent=ptr;
if(item>ptr->data)
ptr=ptr->right;
else
ptr=ptr->left;
}
if(item<parent->data)
parent->left=p;
else
parent->right=p;
}

}
void bst::inordertrav()
{
inorder(root);

}
void bst::inorder(tree_node *ptr)
{

if(ptr!=NULL)
{

inorder(ptr->left);
cout<<" "<<ptr->data<<" ";
inorder(ptr->right);
}
}
void bst::preordertrav()
{
preorder(root);

}
void bst::preorder(tree_node *ptr)
{

if(ptr!=NULL)
{
cout<<" "<<ptr->data<<" ";
preorder(ptr->left);
preorder(ptr->right);
}

}
int main()
{
bst b;
b.insrt(52);
b.insrt(25);
b.insrt(50);
b.insrt(15);
b.insrt(40);
b.insrt(45);
b.insrt(20);
cout<<"inorder"<<endl;
b.inordertrav();
cout<<endl<<"postorder"<<endl;
b.postordertrav();
cout<<endl<<"preorder"<<endl;
b.preordertrav();
getch();
}
getting error ld return 1 exit

Is that really everything that the compiler/liker say?

Perhaps "postordertrav" or "podtorder" in the message?


Please use code tags when posting code. Much more readable. See http://www.cplusplus.com/articles/jEywvCM9/
You can edit your post to add the tags.
Last edited on
after I got rid of cornholio and getch, I get this error:

undefined reference to `bst::postordertrav()

which in the code has a header but no body. You need to write this function!
Last edited on
Topic archived. No new replies allowed.