我正在尝试为家庭作业项目重载 << 运算符。我不断收到错误代码 4430 缺少类型说明符 - 假定为 int。注意:C++ 不支持默认输入。任何帮助都会很棒!
//EmployeeInfo is designed to hold employee ID information
#ifndef EMPLOYEEINFO_H
#define EMPLOYEEINFO_H
#include <iostream>
#include <ostream>
using namespace std;
std::ostream &operator << (std::ostream &, const EmployeeInfo &);
class EmployeeInfo
{
private:
int empID;
string empName;
public:
//Constructor
EmployeeInfo();
//Member Functions
void setName(string);
void setID(int);
void setEmp(int, string);
int getId();
string getName();
string getEmp(int &);
//operator overloading
bool operator < (const EmployeeInfo &);
bool operator > (const EmployeeInfo &);
bool operator == (const EmployeeInfo &);
friend std::ostream &operator << (std::ostream &, const EmployeeInfo &);
};
friend std::ostream operator<<(std::ostream &strm, const EmployeeInfo &right)
{
strm << right.empID << "\t" << right.empName;
return strm;
}
#endif