通讯录链表实现之C++

前言

在mooc上学习了链表中的顺序表和单链表,并使用单链表数据结构跟着老师完成通讯录创建。通过这次链表练习使用,做一些总结。

自顶向下设计探索。

功能需求

在功能实现上,通讯录主要包括,创建联系人,删除联系人,显示联系人,退出通讯录。

通讯录

  1. 创建联系人
    1. 联系人信息
    2. 插入到存储结构中
  2. 删除联系人
    1. 获取删除联系人编号
    2. 删除联系人
  3. 显示联系人
    1. 遍历存储结构
  4. 退出通讯录
    1. 退出控制台

 

软件设计

  1. 模块划分
    1. 主控模块(主函数)
    2. 命令读取模块
    3. 命令解析模块
    4. 命令处理模块
  2. 结构划分
    1. 链表结构
      1. 构建函数
      2. 析构函数
      3. 清空
      4. is空
      5. 长度
      6. 获取节点
      7. 节点位置
      8. 前驱
      9. 后继
      10. 插入
      11. 删除
      12. 插入头
      13. 插入尾
      14. 遍历
    2. 节点结构
      1. 数据域
      2. 指针域
      3. 函数
    3. 数据域结构
      1. 姓名
      2. 电话
      3. 函数

 

 

附录:


链表头文件相关声明定义

List.h

#ifndef LIST_H
#define LIST_H

#include "Node.h"

class List
{
public:
	List();
	~List();
	void ClearList();
	bool ListEmpty();
	int ListLength();
	bool GetElem(int i, Node *pNode);
	int LocateElem(Node *pNode);
	bool PriorElem(Node *pCurrentNode, Node *pPreNode);
	bool NextElem(Node *pCurrentNode, Node *pNextNode);

	bool ListInsert(int i, Node *pNode);
	bool ListDelete(int i, Node *pNode);
	bool ListInsertHead(Node *pNode);
	bool ListInsertTail(Node *pNode);
	
	void ListTraverse();

private:
	Node *m_pList;
	int m_iLength;
};


#endif

 

节点头文件相关声明定义 

Node.h

#ifndef NODE_H
#define NODE_H

#include "Person.h"
class Node
{
public:
	Person date;
	Node *next;
	void printNode();
};

#endif

  

数据域相关声明定义

Person.h

#ifndef PERSON_H
#define PERSON_H

#include <string>
#include <ostream>

using namespace std;

class Person
{
	friend ostream &operator<<(ostream &out, Person &person);  //Global Function
public:
	string name;
	string phone;

	Person &operator=(Person &person);
	bool operator==(Person &person);
};

#endif

  

 

转载于:https://www.cnblogs.com/stonebloom-yu/p/6585694.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值