电话本的功能在menu菜单里完全体现了:
cout << "这是一个电话本程序,可以执行以下操作:" << endl;
cout << "1->搜索一个电话" << endl;
cout << "2->增加一个电话" << endl;
cout << "3->删除一个电话" << endl;
cout << "4->查看电话本" << endl;
cout << "5->将文件追加到“电话本.txt”后面" << endl;
cout << "6->将文件读到内存并且输出到命令行" << endl;
cout << "7->清屏" << endl;
cout << "0->退出" << endl;
- #include"iostream"
- #include"cstdlib"
- #include"string"
- #include"fstream"
- #include"utility"
- #include"vector"
- #include"windows.h"
- using namespace std;
-
- class number
- {
- private:
- string name;
- string num;
- public:
- void search(string);
- void add();
- void del(string);
- void show(string);
- void copy();
- friend ostream &operator <<(ostream &output,const number &p)
- {
- output << p.name << endl;
- output << p.num << endl;
- return output;
- }
-
- void input()
- {
- cout << "请输入姓名:" << endl;
- cin >> name;
- cout << "请输入电话:" << endl;
- cin >> num;
- }
- number(string name1=" ",string num1=" ")
- {
- this->name = name1;
- this->num = num1;
-