10行代码!
古布 2004-05-05 10:57:51 typedef struct CSTree {
int data;
struct CSTree *firstchild, *nextsibling;
} *CSTree;
void DestroyTreeOne( CSTree& T ) // #1
{
if ( T ) {
if ( T->firstchild)
DestroyTree( T->firstchild);
if ( T->nextsibling)
DestroyTree( T->nextsibling);
delete T;
T = NULL;
}
}
void DestroyTreeTwo( CSTree& T ) // #2
{
if ( T ) {
if ( T->firstchild)
DestroyTree( T->firstchild);
if ( T->nextsibling)
DestroyTree( T->nextsibling);
delete T;
}
T = NULL;
}
#1和#2有什么区别?哪个有问题?为什么?谢谢!!