/*使用循环双向链表,实现名胜信息管理系统,可实现插入,删除,查询,文件读取,存储,有序归并,输出的功能*/ #include #include #include using namespace std; class CScene //景点类 { private: string name; //景点名 string city; //所在城市 float ticket; //票价 friend class CSceneNode; //结点友元类 friend class CSceneList; //链表友元类 friend class CSceneView; //视图友元类 public: CScene():name("unknown"),city("unknown"),ticket(0){} //构造函数 CScene(CScene &s) //拷贝构造函数 { name=s.name; city=s.city; ticket=s.ticket; } CScene(string n,string c,float t) //构造函数 { name=n; city=c; ticket=t; } void OutputScene() //输出函数 { cout<>name>>city>>ticket; } }; class CSceneNode //结点类 { private: head length a1 a2 a3 CScene scene; //内嵌对象 CSceneNode *prior; //指向前驱 CSceneNode *next; //指向后继 friend class CSceneList; //链表友元类 friend class CSceneView; //视图友元类 public: CSceneNode():next(NULL),prior(NULL),scene(){} //构造函数 CSceneNode(CScene s):next(NULL),prior(NULL),scene(s){} //构造函数 }; class CSceneList //链表类 { private: string listname; //链表名 int length; //表长 CSceneNode *head; //头指针 friend class CSceneView; //视图友元类 public: CSceneList():listname("未分类"),length(0) //构造函数 { head=new CSceneNode; head->prior=head; head->next=head; } ~ CSceneList() //析构函数 { CSceneNode *p,*q; for(p=head->next;p!=head;p=q) { q=p->next; delete p; } delete head; head=NULL; } void Output() //输出全部 { cout<<"--------------"<next,j=1;p!=head;p=p->next,j++) { cout<