我仍然是二维数组的新手,但我试图让一些异常处理来处理这个问题:
const int employee = 3; // number of employees
const int age = 4; // number of ages
int employeesAge[employee][age] = { {50 , 0 , 45, 101}, {45, 6 ,7, 8} , {25 , 8,0, 35}}
for(int i =0; i < employeesAge[employee][age]; i++)
if(employeesAge[employee][age] < 0 || employeesAge[employee][age] > 100)
{
try
{
throw employeesAge[employee][age];
}
catch(int param)
{
cout << "employee can't be under 0 age or over 100 to work here" << endl;
}
}
现在我什至不确定我所做的是否可能,但这是我得到的错误:
uninitialized local variable 'employeesAge' used
如果有人可以提供帮助,将不胜感激。现在我考虑一下,我认为我拥有的 for 语句不是有效或必要的。