using namespace std;
class DblList;
class DblListNode
{
friend class DblList;
public:
int data;
DblListNode llink,rlink;
};
class DblList
{
public:
Dbllist()
{
first=new DblListNode();
first->llink=first->rlink=first;
}
void Insert(DblListNode,DblListNode);
void Delete(DblListNode);
//private:
public:
DblListNode first;
};
void DblList::Insert(DblListNode p,DblListNode x)//p表示新插入的节点插入x节点的右边
{
p->llink=x;
p->rlink=x->rlink;
x->rlink->llink=p;
x->rlink=p;
}
int main()
{
cout<<"ok"<<endl;
DblList intList;
DblListNode node1,node2,node3,node4;
node1.data=10;
node2.data=20;
node3.data=30;
node4.data=40;
intList.Insert(&node1,intList.first);//指针所以加&
// intList.Insert(&node2,intList.first);
// intList.Insert(&node3,intList.first);
// intList.Insert(&node4,intList.first);
cout<<intList.first->rlink->data<<endl;
return 0;
}