学习简单链表-C++
发布时间
阅读量:
阅读量
SinglyLinkedList.h
#include<stdlib.h>
#include<iostream>
class node{
public:
int data;//结点的值
node *next;//保存后继结点的地址
node(){
data = -1;
next = NULL;
}
//构造方法,方便快速创建结点
node(int data,node *next){
this->data = data;
this->next = next;
}
};
class List{
private:
node* head;//指向表头(表头恒为空)
int lenth;//单链表当前最大下标值
bool check(int index);//工具方法,检测index合法性
public:
全部评论 (0)
还没有任何评论哟~
