⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.cpp

📁 虚基类的实现
💻 CPP
字号:
// List.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include <iostream>
using namespace std;

#include "Node.h"
#include "StringObject.h"
#include "list1.h"

int main(void)
{
	Node *P1;
	StringObject *p;
	list list1,list2,list3;
	char *a[5]={"dog","cat","bear","sheep","ox"},*sp="cat";
	int i;

	
	for(i=0;i<5;i++)
	{
		p=new StringObject(a[i]);
		P1=list1.CreatNode();         
		P1->Linkinfo(p);             
		list1.InsertFront(P1);        

		
		p=new StringObject(a[i]);
		P1=list2.CreatNode();
		P1->Linkinfo(p);
		list2.InsertRear(P1);
	}

	list1.PrintList();
	cout<<"list1长度:"<<list1.Length()<<endl;
	list2.PrintList();
	cout<<"要求删除的字符串\"cat\""<<endl;
	
	p=new StringObject(sp);
	P1=list1.Find(*p);
	delete p;
	if(P1!=NULL)
	{
		cout<<"删除cat"<<endl;
		P1=list1.DeleteNode(P1);
		delete P1;
		list1.PrintList();
		cout<<"list1长度:"<<list1.Length()<<endl;
	}
	else
	{
		cout<<"未找到"<<endl;
	}

	cout<<"清空list1"<<endl;
	list1.MakeEmpty();
	list1.PrintList();

	for(i=0;i<5;i++)
	{
		p=new StringObject(a[i]);
		P1=list3.CreatNode();
		P1->Linkinfo(p);
		list3.InsertOrder(P1);
	}

	list3.PrintList();
	cout<<"程序结束"<<endl;

	return 0;
}

⌨️ 快捷键说明

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