一切都正常,只在最后一步运行出不能读
#include<iostream.h>template<class T>
struct BiNode
{
T data;
BiNode<T> *lchild,*rchild;
};
template<class T>
class erchashu
{
public:
erchashu(int a[],int n);
void insert(BiNode<T> *root,BiNode<T> *s);
private:
BiNode<T> *root;
BiNode<T> *s;
};
template<class T>
void erchashu<T>::insert(BiNode<T> *root,BiNode<T> *s)
{
if(root==NULL)
root=s;
else if(s->data<root->data) insert(root->lchild,s);
else insert(root->rchild,s);
}
template<class T>
erchashu<T>::erchashu(int a[],int n)
{
for(int i=0;i<n;i++)
{
s=new BiNode<T>;s->data=a[i];
s->lchild=s->rchild=NULL;
insert(root,s);
}
}
void main()
{
int we[]={53,12,26,56,89,15,42,36};
erchashu<int> b(we,8);
}
一切都正常,只在最后一步运行出不能读,什么原因