xcode - 此处错误: 'Employee' does not refer to a value

标签 xcode class compiler-errors

我正在进行编程任务,但有9个相同的错误。所有所说的“雇员”都不是指值(value)。有人可以帮帮我吗?!非常感谢。下面是我遇到错误的地方,然后还包括了我的类(class)。 ![在此处输入图片描述] [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;
}

最佳答案

声明“类Employee”仅定义类的结构。它不会分配任何内存来存储其值。您需要在某个地方分配该类的实例。

编辑:

实际上,实例是通过输入变量传递到函数中的。您需要在cin和cout语句中访问那些实例(不是类)。

关于xcode - 此处错误: 'Employee' does not refer to a value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27260800/

相关文章:

c++ - ValueError : ['path' ] when installing pyfim

java - 为什么我有不兼容的类型?

iphone - 如何构建通用ios静态库

objective-c - 未知日志 wx=wy=rx=ry=ios

ios - 无论如何在 Cocoapods 中使用预编译时在源代码和二进制文件之间切换

php - Prestashop Collection 加入数据库

c++ - 类更改其他类的数据成员

c++ - C++错误: C4430 and C2143 Error at an impossible place

iphone - 添加 ASIHTTPRequest 时收到 apple O Linker Error

python - 将python语句转换为字符串