EmailaddressbookmanagementprogramEmailaddressbookincludestwotypesofemailaddress:uGeneraladdress,includeinformation:emailaddress(unique),name,phonenumberuGroupaddress,includeinformation:emailaddress(unique),name,listofaddress(eachaddressmaybeageneraladdressoragroupaddress).WriteanEmailaddressbookmanagementprogramwithC/C++language:uGiveanemailaddress,finditsinformation.Ifgivenaddressisagroupaddress,shouldlistallthegeneraladdressesinthisgroup.uAdd/Removeoneemailaddress.uReademailaddressbookfromasourcefile.uSaveemailaddressbooktoadestinationfile.**********************\\myclass.h:\\********************************//此文档用于定义信息类#includeiostream.hclassInfo//基类包含主要邮件地址和名字。{public:voidPRIENT(){coutendlpAddrendl;coutName:pNameendl;}charpAddr[100];charpName[100];};classGenInfo:publicInfo//通用派生类,包含电话号码。{public:voidPRIENT(){Info::PRIENT();coutPhoneNumber:pPNumendl;coutendl;}charpPNum[20];};classGroInfo:publicInfo//群组派生类,包含成员列表。{public:GroInfo(intGen=0,intGro=0){this-Gen=Gen;this-Gro=Gro;}voidPRIENT()//打印群组类通用成员邮件列表;{Info::PRIENT();coutendlThegeneraladdressesinthisgroup:endl;}intGen,Gro;intpGenAddrs[1000];intpGroAddrs[200];};**********************\\Emailaddressbookmanagement.cpp:\\********************************//Emailaddressbookmanagement.cpp:定义控制台应用程序的入口点。//作者:孙干余。#includestring.h#includemyclass.h//用于存放类成员//#includestdlib.h#includefstream.h#includeiostream.hifstreamfin;//源文件指针对象ofstreamfout;//目标文件指针对象GenInfo*GenMember[1000];//通用类对象指针数组GroInfo*GroMember[200];//群组类对象指针数组charTest[100];intm=0,n=0;//m存放通用类对象总个数,n用来存放群组类对象总个数。charpAddr[50],pName[50],pPNum[20];//主邮件地址,名字,电话号码(通用类独有),intpNOGenAddrs[100],pNOGroAddrs[20];//通用类及群组类邮件个数(群组类独有)charch;//用于接收指令及吸收多余字符charpSFName[100],pDFName[100];//源文件名,目标文件名voidFileOpen(void);voidConstruct(void);//将文件内容建立到内存voidInquires(void);//查询函数voidModifiedItem(void);//修改单个条目函数voidNew(void);voidDelete(void);voidFileSave(void);intmain(void){system(color3f);//换个颜色,眼睛舒服一点.for(intk=0;k100;GenMember[k++]=NULL){};//将指针数组赋空值.for(intk1=0;k20;GroMember[k1++]=NULL){};cout********WelcometotheEmailaddressbookmanagementsystem!********endl;FileOpen();Construct();intorder=1;//用于接收命令.while(1){cout*****************************MainMenu******************************endl;//命令菜单界面cout1.CriteriaQueryendl;//标准化对象查询cout2.Addemailaddressesendl;cout3.Deleteemailaddressesendl;cout4.Modifyemailaddressesendl;cout5.CleanSreenendl;//退出系统cout6.saveandlogoutendl;//清除屏幕cout*******************************************************************endl;coutInputcommandoptions:;cinorder;switch(order){case1:{Inquires();}break;case2:{New();}break;case3:{Delete();}break;case4:{ModifiedItem();break;}case5:{system(cls);break;}case6:{FileSave();}default:coutInputcommanddoesnotexist!endl;break;}}return0;}voidFileOpen(void){/*本函数用于打开源文件及目标文件*/while(true){coutInputtheURLofasourcefile:endl;cinpSFName;fin.open(pSFName);if(!fin.is_open())//文件打开失败{coutOpenattemptfailed.PleasereentersourcefileURL:endl;}else{break;}}coutFileisopenedsuccessfully!endl;return;}voidFileSave(void){while(true){coutInputtheURLofadestinationfile:endl;cinpDFName;fout.open(pDFName);if(!fout.is_open())//文件打开失败{coutOpenattemptfailed.PleasereenterdestinationfileURL:endl;}else{break;}}for(inti=0;i=m;i++)//向文件中写入个人邮件部分{fout'#'iendl;fout''GenMember[i]-pAddrendl;foutGenMember[i]-pName;foutendlGenMember[i]-pPNum;foutendlendlendl;}for(intix=0;ix=n;ix++)//向文件中写入群组邮件部分{fout'G'iendl;foutGroMember[ix]-pAddrendl;foutGroMember[ix]-pNameendl;foutendl;for(intk=0;k=GroMember[ix]-Gen;k++){foutGroMember[ix]-pGenAddrs[k]endl;}fout-1endl;for(intkk=0;GroMember[ix]-pGroAddrs[kk]!='\0';kk++)foutGroMember[ix]-pGroAddrs[kk]endl;fout-1endlendlendl;}fin.close();fout.close();coutFliesaved.Thankyouforusing.Pressanykeytologoff......endl;system(pause);exit(0);}voidConstruct(void){//本函数用于从源文件中读取数据,在内存中建立目录intGen=0,Gro=0;//Gen用来存放群组邮件中个人邮件成员的个数,Gen用于存放群邮件成员。inti=0,gen=0,gro=0;//gen和gro用来存放成员列表的单个项的值。。finch;while(fin.fail()==false){switch(ch){case'#':{finm;finch;fin.getline(pAddr,49);fin.getline(pName,49);fin.getline(pPNum,19);GenMember[m]=newGenInfo;//这是之前写的,其实也可以先new,然后直接cinGenMember[m]-成员。strcpy(GenMember[m]-pAddr,pAddr);strcpy(GenMember[m]-pName,pName);strcpy(GenMember[m]-pPNum,pPNum);}break;case'G':{Gen=0;Gro=0;finn;GroMember[n]=newGroInfo(Gen,Gro);//实例化一个群组对象finch;fin.getline(pAddr,49);//.getline是C++方法。fin.getline(pName,49);finch;//吸收一个字符,是我用来控制格式的findecgen;//读取群组对象中通用成员的个数while(gen!=-1){GroMember[n]-pGenAddrs[Gen++]=gen;findecgen;}GroMember[n]-pGenAddrs[Gen]='\0';Gen--;//因为Gen在循环结束后比实际值大1了,所以要减去1。findecgro;//读取群组对象中群组成员的个数while(gro!=-1)//-1也是自己设置的控制字符。{GroMember[n]-pGroAddrs[Gro++]=gro;findecgro;}GroMember[n]-pGroAddrs[Gro]='\0';Gro--;strcpy(GroMember[n]-pAddr,pAddr);strcpy(GroMember[n]-pName,pName);GroMember[n]-Gen=Gen;GroMember[n]-Gro=Gro;}break;default:finch;break;//如果是换行则继续前移,进