我从事编程工作,我有9个相同的错误。所有这些都说''员工'不是指价值。有人可以帮帮我吗?!非常感谢提前。下面是我收到错误的地方,然后我也包括了我的课程。 ![在此输入图像说明] [1]
类别:
#ifndef Programming_Assignment__3_employee_h
#define Programming_Assignment__3_employee_h
#include <string>
class Employee
{
private:
int ID;
std::string ssn;
std::string emailaddress;
int yearOfbirth;
public:
static std::string name;
Employee();
int displayRecord();
void addEmployee();
int GetID();
std::string GetEmail();
};
#endif
错误:
int displayRecord(vector <Employee*> input)
{
cout << " ______________________________";
for ( int count = 0; count < 200; count ++)
{
std::getline(Employee.name);
cout << setw(5) << Employee.ID << setw(15) << Employee.name << setw(15) << setw(15) << Employee.emailAddress << setw(8)<< Employee.yearOfBirth;
}
}
void addemployee(vector <Employee*> input)
{
cout << "Employee ID : " << endl;
cin >> Employee.ID;
cout << "Employee Name: ";
cin>> Employee[input].name;
cout << "SSN :";
cin >> Employee[input].ssn;
cout << "Email Address: ";
cin >> Employee[input].emailAddress;
cout << "Birth Year: ";
cin >> Employee[input].yearOfBirth;
}
答案 0 :(得分:1)
宣布&#34;班级员工&#34;只是定义了类的结构。它不会分配任何内存来存储其值。你需要在某处分配一个类的实例。
编辑:
实际上,实例通过输入变量传递给函数。您需要在cin和cout语句中访问这些实例(而不是类)。