C++通讯录
花了半天时间,利用C++中的vector容器、迭代器实现了通讯录的简单功能,更直接的见识了C++与C语言之间的差别,封装真的是超级方便啊~
下面贴出我的代码,希望对大家有所帮助~
addr.h:
#ifndef _ADDR_H_
#define _ADDR_H_
#include <iostream>
using namespace std;
class Addr
{
public:
friend ostream& operator<<(ostream& out,const Addr& s);
Addr();
void Interface();
void Choose();
void Input();
void Display();
void Search();
void MyDelete();
~Addr();
private:
int id;
char name[1024];
char tel[1024];
char address[1024];
};
#endif
addr.cpp:
#include <iostream>
#include <vector>
#include "addr.h"
using namespace std;
vector<Addr> a;
static int ID = 1;
ostream& operator << (ostream& out,const Addr& s)
{
out << s.name;
return out;
}
Addr :: Addr()
{
cout << "Welcome to Address_Book!" << endl;
}
Addr :: ~Addr()
{
}
void Addr :: Interface()
{
system("clear");
cout << "+================&#