Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement a simple address Book Management system on C++

Shulou Source: shulou.com Published: 2022-06-01 12:00:42 09月30日 Update

This article introduces the relevant knowledge of "how to achieve a simple address book management system on C++". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Code # include # include using namespace std;// customize a contact node type typedef struct node1 {string name; / / name string tel; / / Mobile number string email; / / mailbox string address; / / address struct node1 * next; / / pointer to the next node} Node / / customize a binary sort tree node type typedef struct node2 {Node data; struct node2 * lchild, * rchild;} BSTNode;// to construct the node communication class class Fnode {public: Fnode (); / / constructor, which is used to initialize some variables ~ Fnode () / / destructor, which is used to clean the allocated memory after the end of the program void CreateInfo (); / enter contact information void InsertInfo (); / insert contact information void FindInfoName (); / / find contact information by name void FindInfoTel () / / find contact information by mobile phone number void DeleteInfoTel (); / delete contact information by mobile phone number void DispInfo (); / print all contact information void DispInfoSort (); / / output contact information by name void SaveInfoToFile () / / Save contact information to file void ReadInfoFromFile (); / / read contact information from file void Run (); / / function, including menu and related functions entry bool InsertBST (BSTNode * & bt, Node key); / / insert binary sort tree node to recursively implement void CreateBST () / / create a binary sort tree void InOrder (BSTNode * b) from the linked list; / / iterate through the output binary sort tree and recursively implement void DestroyBST (BSTNode * & b); / / release the binary sort tree and recursively implement private: bool opened / / used to indicate whether the file has been read, not read as 0, read as 1 Node * L, * p, * Q; / / define the header pointer of the address book node and the pointer BSTNode * btree; / / binary sort tree head node that may be used in other member functions}; / / constructor to initialize some variables Fnode::Fnode () {L = new Node; L-> next = NULL P = Q = NULL; btree = NULL; opened = 0;} / / destructor, which is used to clean the allocated memory after the end of the program Fnode::~Fnode () {p = L; while (p! = NULL) {delete p; p = p-> next;}} void Fnode::CreateInfo () / / create the node {int n; q = L, p = NULL While (Q-> next! = NULL) Q = Q-> next; cout > n; for (int I = 0; I

< n; i++) { p = new Node; cout >

P-> tel > > p-> email > p-> address; p-> next = Q-> next; Q-> next = p; Q = p;}} / / insert contact information void Fnode::InsertInfo () {Q = L, p = NULL; while (Q-> next! = NULL) Q = Q-> next; p = new Node; cout p-> name > > p-> tel > > p-> email > > p-> address; p-> next = Q-next Q-> next = p; cout

Tags: Contacts contacts information names mobile phones mobile numbers menus sorting files functions addresses mailboxes output communications address books data nodes management systems systems management Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL Linux Redmi Microsoft