//具有插入功能的查找(非递归)
void BSTree::inst1(Sstudent el)
{
BTreeNode *p,*q;
int tag;
tag=0;
p=root;
while ((p != NULL)&& (tag == 0))
{
q= p;
if (el < p->data)
p=p->lchild;
else if (el > p->data)
p=p->rchild;
else
tag=1;
}
if (tag == 0)
{
p=new BTreeNode(el,NULL,NULL);
if (root==NULL) root=p;
else if (el < q->data) q->lchild= p;
else q->rchild=p;
}
}
刚才在VS2013编译的时候,提示 error C4703: potentially uninitialized local pointer variable 'q' used (22行)。
q的作用范围不是整个函数吗?