本文整理汇总了C++中Notebook::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ Notebook::remove方法的具体用法?C++ Notebook::remove怎么用?C++ Notebook::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notebook
的用法示例。
在下文中一共展示了Notebook::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
Notebook my;
my.export_notes("notebook");
cout << "------------------\n"
<< "Select action:\n"
<< "1) Add note\n"
<< "2) Find note\n"
<< "3) Remove note\n"
<< "4) Show all notes\n"
<< "q) Close notebook\n"
<< "------------------\n";
char ans;
ans = cin.get();
while (((ans < '1') || (ans > '4')) && (ans != 'q')) {
if (ans != '\n')
while (cin.get() != '\n');
cout << "Please, enter correct command: ";
ans = cin.get();
}
while (cin.get() != '\n');
while (tolower(ans) != 'q') {
switch (ans) {
case '1' : {
char name[100] = {};
cout << "Enter name: ";
cin.getline(name, 99);
char phone[100] = {};
cout << "Enter phone: ";
cin.getline(phone, 99);
if (!my.find(name))
my.add(name, phone);
else {
cout << "Note " << name << " is already exist, replace? [y/n]: ";
char ch;
ch = cin.get();
ch = tolower(ch);
if (ch != '\n')
while (cin.get() != '\n');
while (ch != 'y' && ch != 'n') {
cout << "Enter y or n: ";
ch = cin.get();
ch = tolower(ch);
if (ch != '\n')
while (cin.get() != '\n');
}
if (tolower(ch) == 'y')
my.add(name, phone);
}
break;
}
case '2' : {
char name[100] = {};
cout << "Enter name: ";
cin.getline(name, 99);
char const * res = my.find(name);
if (res == nullptr)
cout << name << " not found\n";
else
cout << name << ": " << res << endl;
break;
}
case '3' : {
char name[100] = {};
cout << "Enter name: ";
cin.getline(name, 99);
if (!my.find(name))
cout << name << " not found\n";
else {
cout << "Confirm removal " << name << " [y/n]: ";
char ch;
ch = cin.get();
ch = tolower(ch);
if (ch != '\n')
while (cin.get() != '\n');
while (ch != 'y' && ch != 'n') {
cout << "Enter y or n: ";
ch = cin.get();
ch = tolower(ch);
if (ch != '\n')
while (cin.get() != '\n');
}
if (tolower(ch) == 'y')
my.remove(name);
cout << "Removal " << name << " complete\n";
}
break;
}
case '4' :
my.show_all();
}
cout << "\n------------------\n"
//.........这里部分代码省略.........