本文整理汇总了C++中SymTab::Remove方法的典型用法代码示例。如果您正苦于以下问题:C++ SymTab::Remove方法的具体用法?C++ SymTab::Remove怎么用?C++ SymTab::Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymTab
的用法示例。
在下文中一共展示了SymTab::Remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char * const * argv) {
char buffer[BUFSIZ];
char command;
long number;
char option;
SymTab<UCSDStudent>::Set_Debug_Off ();
while ((option = getopt (argc, argv, "x")) != EOF) {
switch (option) {
case 'x': SymTab<UCSDStudent>::Set_Debug_On ();
break;
}
}
SymTab<UCSDStudent> ST;
ST.Write (cout << "Initial Symbol Table:\n" );
while (cin) {
command = NULL; // reset command each time in loop
cout << "Please enter a command ((i)nsert, "
<< "(l)ookup, (r)emove, (w)rite): ";
cin >> command;
switch (command) {
case 'i': {
cout << "Please enter UCSD student name to insert: ";
cin >> buffer; // formatted input
cout << "Please enter UCSD student number: ";
cin >> number;
UCSDStudent stu (buffer, number);
// create student and place in symbol table
ST.Insert (stu);
break;
}
case 'l': {
unsigned long found; // whether found or not
cout << "Please enter UCSD student name to lookup: ";
cin >> buffer; // formatted input
UCSDStudent stu (buffer, 0);
found = ST.Lookup (stu);
if (found)
cout << "Student found!!!\n" << stu << "\n";
else
cout << "student " << buffer << " not there!\n";
break;
}
case 'r': {
unsigned long removed;
cout << "Please enter UCSD student name to remove: ";
cin >> buffer; // formatted input
UCSDStudent stu (buffer, 0);
removed = ST.Remove(stu);
if (removed)
cout << "Student removed!!!\n" << stu << "\n";
else
cout << "student " << buffer << " not there!\n";
break;
}
case 'w':
ST.Write (cout << "The Symbol Table contains:\n");
}
}
ST.Write (cout << "\nFinal Symbol Table:\n");
}