struct node
{
int t; //数据
node *next;//指向下一个节点
node(int data):t(data),next(NULL)// 初始化列表 结构体和类一样也可以有构造函数 只是默认是公有的 而类默认是私有
{
}
};
//显示所有数据的函数
void showNode(node* head)
{
while(head!=NULL)
{
cout<<head->t<<endl;
head=head->next;
}
}
int main()
{
node a(1),b(2),c(3),d(4);
node e(5);
a.next=&b;
b.next=&c;
c.next=&d;
node* &p = b.next; //在b 和c 中间插入一个节点
e.next=p;
p=&e;
showNode(&a);
}