0
我的问题是关于将信息输入到一个数组的元素。我已经创建了一个[2] [3]数组,现在正试图为数组的每个元素添加一个年龄,id和薪水。我的代码的最底部我试图在我的所述阵列的第一元件在设置这些值和它强调“employeeArray”,并说表达必须具有值的类型。现在我相当肯定,我正确地设置了值,所以我想知道是否我的代码中的其他位置缺少一些初始化,指针等。我在下面附C++输入多个值时为二维的元件阵列
class Employee
{
private:
int age;
int id;
float salary;
public:
Employee()
{
age = 0;
id = 0;
salary = 0;
}
void setAge(int x)
{
age = x;
}
void setId(int x)
{
id = x;
}
void setSalary(float x)
{
salary = x;
}
int getAge();
int getId();
float getSalary();
};
int Employee::getAge()
{
return age;
}
int Employee::getId()
{
return id;
}
float Employee::getSalary()
{
return salary;
}
int main()
{
const int rows = 2;
const int columns = 3;
int employeeArray[rows][columns];
employeeArray[0][1].setAge(30);
employeeArray[0][1].setId(111);
employeeArray[0][1].setSalary(30000);