猿问

求大神看看,一个关于类的电话簿,如何实现删除功能?

#include<iostream>
#include<string>
using namespace std;
class Id
{
public:
Id(){};
int tel;
void init(){
cout<<name<<" "<<tel<<endl;
}
void del()
{
}
void print()
{
cin>>name>>tel;
}
void ct()
{
cin>>name>>tel;
}
};
int main()
{
cout<<"请输入查看(check),查看全部(checkall),增添(add),修改(change)或删除(delete)"<<endl;
Id a[10];
string b;
int n;
while(cin>>b)
{
if(b=="add")
{
cout<<"请输入您要增添几位联系人(但请不要超过十人):"<<endl;
cin>>n;
for(int i=0;i<n;i++)
a[i].print();
cout<<"请输入查看(check),查看全部(checkall),增添(add),修改(change)或删除(delete)"<<endl;
}
else if(b=="checkall")
{
cout<<"请输入您要查看几位联系人:"<<endl;
cin>>n;
for(int i=0;i<n;i++)
a[i].init();
cout<<"请输入查看(check),查看全部(checkall),增添(add),修改(change)或删除(delete)"<<endl;
}
else if(b=="check")
{
cout<<"请输入您要查看第几位联系人:"<<endl;
cin>>n;
for(int i=n-1;i<n;i++)
a[i].init();
cout<<"请输入查看(check),查看全部(checkall),增添(add),修改(change)或删除(delete)"<<endl;
}
else if(b=="change")
{
cout<<"请输入您要修改第几位联系人:"<<endl;
cin>>n;
for(int i=n-1;i<n;i++)
a[i].ct();
cout<<"请输入查看(check),查看全部(checkall),增添(add),修改(change)或删除(delete)"<<endl;
}
else if(b=="delete")
{
cout<<"请输入您要删除第几位联系人:"<<endl;
cout<<"请输入查看(check),查看全部(checkall),增添(add),修改(change)或删除(delete)"<<endl;
}
}
}

玩儿会
浏览 1406回答 0
0回答
随时随地看视频慕课网APP
我要回答