my_list.h

来自「实现对链表中对象的基本操作」· C头文件 代码 · 共 40 行

H
40
字号
#include<iostream.h>   //类的定义要写在.h文件中,函数只需要声明就可以,在.cpp文件中不能再有类的定义

class Item
{
	public:
		friend class MY_List;
	private:
		Item(int d=0)
		{data=d; next=0;}
		Item *next;
		int data;
};

class MY_List
{
	public:
		MY_List()
			{list=0;}
		MY_List(int d)
			{list=new Item(d);}
		int Print();
		int Insert(int d=0);
		int Append(int d=0);
		void Cat(MY_List &il);
		void Reverse();
		int Length();
	private:
		Item *end();
		Item *list;
};


int MY_List::Print();
int MY_List::Insert(int d);
int MY_List::Append(int d);
Item *MY_List::end();
void MY_List::Cat(MY_List &il);
void MY_List::Reverse();
int MY_List::Length();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?