今天和昨天用C++编写了一个简单的通讯录,功能比较简单,基本功能实现
信息也比较简单,就是ID号,姓名,电话和住址
基本功能:1、插入新信息 2、查看信息 3、删除信息 4、修改信息
用了两个类,一个是封装了基本信息,一个是封装了需要用到的函数
Person.h
#ifndef _PERSON_H_
#define _PERSON_H_
#include"PersonTool.h"
class Person
{
private:
int id_;
char name[20];
char phone[20];
char addr[20];
public:
static int temp;
int Printstudent();
void setID(int id);
void setPhone();
void setName();
void setAddr();
int getID();
char* getPhone();
char* getName();
char* getAddr();
//bool operator<(const char*first,const char* second);
Person& operator++();
};
#endif
封装了通讯录里的基本信息
#include<iostream>
#include"Person.h"
using namespace std;
int Person ::temp = 0;
int Person::Printstudent()
{
cout<<"ID: "<<getID()<<endl;
cout<<"name: "<<getName()<<endl;
cout<<"phone: "<<getPhone()<<endl;
cout<<"addr: "<<getAddr()<<endl;
}
void Person::setID(int id)
{
id_ = id;
}
void Person::setName()
{
cout<<"please input your name"<<endl;
cin>>name;
}
void Person::setPhone()
{
cout<<"Please input your phone"<<