Ok, I'm doing my course work and I've managed to get it so that the menu will only show values if they've been entered, for example:

if number_of_employees is 0 
display add employee
display add employee
display view employee

The problem that I'm having is that it's in a switch statement and if someone wants to, somehow view the employees details and there isn't an employee, it's going to be rather difficult. So I thought about using an Exception but it doesn't seem to be working. Here's my code:

case '3': system("cls");
                           system("TITLE View Employees");
                           int choice;
                             cout << "Employee ID: ";
                             cin >> choice;
                             // display the employees details
                             cout << "Employees Name: " << employees[choice + 1].getFirstName() << " " << employees[choice].getLastName() << endl;
                             cout << "Employees Adress: " << employees[choice + 1].getAddress() << endl;
                             cout << "Employee Hours: " << employees[choice + 1].getHours() << endl;
                             cout << "Employee Gross Wage: " << employees[choice + 1].calculateGrossPay() << endl;
                             cout << "Employee Net Wage: " << employees[choice + 1].calculateTax() << endl << endl << endl;
                           catch(char error[255])
                              error = "Error: You cannot view employees since there are none availible";
                              if(number_of_employees == 0)
                              cout << error;

Any suggestions?

>>I thought about using an Exception

There is no need to use exception here because it will only complicate your
code. Why not just display nothing? Or display a message saying
no employees to show. Do something like this :

if(choice == VIEW_EMPLOYEES){
  if(employees.empty()) {
   else displayEmployees();
This article has been dead for over six months. Start a new discussion instead.