我正在开发一个小型数据库项目.我已经创建了一个带有switch()函数的接口,它应该是调用函数和循环,直到我选择"EXIT"选项.我通过将指定的值设置为int Loop变量来控制循环.以这种方式处理这种循环是一种好习惯吗?如果没有,为什么呢?在其他函数中,当我有多个条件时,我甚至使用这种变量两次.也许我应该采用不同的方式?如果我try(), throw(), catch()在这种情况下使用异常是否有意义,那么它会是什么样子?这是我的一段代码:
void mainMenu() {
vector<Employee> firmEmployees;
vector<Intern> firmInterns;
int Loop = 0;
while (Loop == 0) {
cout << endl << endl;
cout << "================ EMPLOYEE DATABASE ================" << endl << endl;
cout << " HIRE NEW EMPLOYEE (1)" << endl;
cout << " MANAGE EMPLOYEES (2)" << endl;
cout << " HIRE NEW INTERN (3)" << endl;
cout << " MANAGE INTERNS (4)" << endl;
cout << " EXIT (5)" …Run Code Online (Sandbox Code Playgroud)