C 通訊錄實現

2021-07-26 21:01:01 字數 1871 閱讀 6456

昨晚實現了用c++編寫通訊錄,深刻的感受到了封裝的便利性啊,vector真是太方便了!!!

**如下:

info.h

#ifndef _person_h_

#define _person_h_

#include #include #include using namespace std;

class info

;#endif

info.cpp

#include "info.h"

vectorper;

int info::count = 0;

int info::getid()

void info::setname()

string info::getname() const

void info::settel()

string info::gettel() const

void info::setaddr()

string info::getaddr() const

info::info()

info::~info()

void info::insert()

}tmp.settel();

tmp.setaddr();

tmp.id = count;

per.push_back(tmp);

cout << "是否繼續新增聯絡人 y/n :";

char ch;

cin >> ch;

if('y' == ch || 'y' == ch)

}void info::show()

else

cout << "請按任意鍵退出" << endl;

char ch;

cin >> ch;

}}void info::search()

else

}}else if(2 == tp)

}}else

if(0 == flag)

else

cout << "請按任意鍵退出" << endl;

char ch;

cin >> ch;

}}void info::delete_info()

else

}else

}}else if(2 == tp)

}else

}}else

if(0 == flag)

else

cout << "請按任意鍵退出" << endl;

char ch;

cin >> ch;

}}void info::modify()

else

case '2':

case '3':

default :}}

else

}else

}if(0 == flag)

if(1 == flag2)

cout << "請按任意鍵退出" << endl;

char ch3;

cin >> ch3;

}

}void info::exit_info()

}void info::choose()

case '2':

case '3':

case '4':

case '5':

case '6':

default:

}}void info::inte***ce()

main.cpp

#include "info.h"

int main()

通訊錄的實現

ifndef contacts h define contacts h define name length 20 define length 10 define tele length 11 define addr length 30 define max 1000 struct peoplein...

通訊錄 靜態實現

address.h ifndef address h define address h include include include include define max 10 這裡我為了除錯方便取了乙個較小的數值 enum op 姓名 性別 年齡 住址 typedef struct pesonm...

通訊錄簡單實現

姓名 性別 年齡 住址 利用構建乙個結構體來儲存資訊,結構體的大小根據所需來自行規定 typedef struct add add typedef struct addnode addnode 關於資訊儲存的方法,最簡單的兩種辦法就是鍊錶跟順序表的結構,簡單說呢就是兩種不同的對資料或者說結構體的應用...