一个简单链表的示例
#include<iostream.h>
struct student
{
char name[20];
int age;
student * next;
};
void main()
{
student c={"Kaka",23,NULL};
student b={"Deco",26,&c};
student a={"Terry",30,&b};
student *head=&a;
student *point=head;
cout<<"head->";
while(point)
{
cout<<(*point).name<<"->"<<(*point).age<<"->";
point=(*point).next;
}
cout<<"End"<<endl;
}
运行结果: