麻烦帮忙菜鸟解答一下
#include <iostream>using namespace std;
class dlink
{
private:
int num;
dlink *pre;
dlink *suc;
public:
dlink()
{
pre = NULL;
suc = NULL;
}
void SetNum(int anit)
{
num = anit;
}
void Append(dlink *p);
};
void dlink::Append(dlink *p)
{
p->suc = suc;
p->pre = this;
this->suc->pre = p;
suc = p;
}
dlink * list_head;
void main()
{
dlink d, d1, d2, *p1, *p2;
d.SetNum(0);
d1.SetNum(1);
d2.SetNum(2);
list_head = &d;
p1 = &d1;
p2 = &d2;
list_head->Append(p1);
list_head->Append(p2);
}
不是很明白这个双链表的中void dlink::Append(dlink *p)这个函数中的四条语句分别是代表什么的,是怎样在链表内添加成员的,麻烦各位高手解答一下,不甚感激!