|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <iostream>
#include <string>
#define MAX 100
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class Contacts
{
public:
void getContacts(string Contacts_name,string Contacts_Gender,int Contacts_Telephone)
{
name=Contacts_name;
Gender=Contacts_Gender;
Telephone=Contacts_Telephone;
}
string getname(){return name;}
string getGender(){return Gender;}
int getTelephone(){return Telephone;}
void AddContacts()
{
}
private:
string name;
string Gender;
int Telephone;
};
class ContactsManager
{
public:
//3õê¼»ˉáaÏμèË£¬n¸öèË
void init(Contacts b[],int n)
{
int i;
for(i=0;i<n;i++) data[i]=b[i];
num=n;
}
//ìí¼óò»¸öáaÏμèË
void addOne(Contacts b)
{
if(num==MAX) {
cout<<"áaÏμèËÂú£¬2»Äüìí¼ó "<<endl;
return;
}
data[num]=b;
num++;
}
private:
Book data[MAX]; //áaÏμèË
int num; //áaÏμèËμÄêyÄ¿
};
int main(int argc, char** argv) {
char ch;
Contacts c[3];
c[1].getContacts("ÕÅèy","ÄD",122456);
c[2].getContacts("àîËÄ","Å®",156232);
c[3].getContacts("íõÎå","ÄD",564898);
//½¨á¢áaÏμèË1üàíàà¶ÔÏó
BooksManager bm;
//3õê¼»ˉáaÏμèË
bm.init(b,4);
cout<<"1.ìí¼óáaÏμèË"<<endl<<"2.ÏÔê¾áaÏμèË"<<endl<<"3.2éÕòáaÏμèË"<<endl<<"4.¸üDÂáaÏμèË"<<endl<<"5.é¾3yáaÏμèË"<<endl;
do
{
ch=getchar();
system("cls");
switch(ch)
{
case '1':
{
Contacts t;
string name;
string Gender;
int Telephone;
cin>>name;
cin>>Gender;
cin>>Telephone;
t.getContacts(name,Gender,Telephone);
bm.addOne(t);
break;
}
case '2':
break;
case '3':
break;
case '4':
break;
case '5':
break;
}
}while(ch>='1' && ch<='5');
return 0;
} |
|