本文整理汇总了C++中Students::deleteStudent方法的典型用法代码示例。如果您正苦于以下问题:C++ Students::deleteStudent方法的具体用法?C++ Students::deleteStudent怎么用?C++ Students::deleteStudent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Students
的用法示例。
在下文中一共展示了Students::deleteStudent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseCommand
//this function takes the command from the cmd into commands that the program knows
void ParseCommand(Command cmd, std::vector<std::string> payload)
{
if (cmd == Invalid)
{
printMessage("Invalid command.");
}
//adds a student
else if (cmd == Add)
{
//Add a student
if (payload.size() != 6)
{
//bad news throw the user an error.
printMessage("Command add recieved incorrect # of arguments.");
}
else
{
//constuct the student
Student toAdd = Student(payload[0], payload[1], payload[2],
std::stoi(payload[3]), std::stoi(payload[4]), std::stoi(payload[5]));
//make sure that id dosent exsist
std::vector<Student> toCheck = students.searchStudents(students.ID, toAdd.getUID());
//if to check == 0 then student doesnt exsist
if (toCheck.size() < 100)
{
//make sure the student is valid
if (!toAdd.isValidStudent())
{
printMessage("Invalid student attribute.");
return;
}
//add
students.addStudent(toAdd);
students.saveStudent();
std::cout << toAdd.getName() + " successfully added" << std::endl;
}
else
{
std::cout << "Student already exists" << std::endl;
}
}
}
//remove a student
else if (cmd == Remove)
{
//see if student exsists
std::vector<Student> toCheck = students.searchStudents(students.ID, payload[0]);
//see if student exsist
if (toCheck.size() != 0)
{
std::cout << "Student does not exist." << std::endl;
}
else
{
//delete student
students.deleteStudent(toCheck[0]);
students.saveStudent();
std::cout << "Student deleted successfully" << std::endl;
}
}
//search for student
else if (cmd == Search)
{
//make sure there are arguments
if (payload.size() == 0)
{
std::cout << "Printing all students:" << std::endl;
students.printAllStudents();
return;
}
else
{
//slit the payload
std::vector<std::string> commands = fileIO::split(payload[0], '=');
//make sure the format is correct
if (commands.size() < 2)
{
printMessage("Search argument recieved invalid. Format should be [email protected]");
}
else
{
Students queryList = Students(students.searchStudents(commands[0],commands[1]));
//iterate through rest of the arguments
for (int i = 1; i < payload.size(); i++)
{
std::vector<std::string> commands = fileIO::split(payload[i], '=');
if (commands.size() != 2)
{
printMessage("Search argument recieved invalid. Format should be [email protected]");
//.........这里部分代码省略.........