没有运算符">>"与这些操作数匹配

No operator ">>" matches these operands

本文关键字:gt 操作数 运算符      更新时间:2023-10-16

我在整个网站中都透彻了,找不到解决我独特问题的解决方案。

编译器不断提出"无操作员">>"与这些操作数匹配"。我尝试使用此代码时的消息:

void readCustomerInfo()
{
ifstream in_stream;
int i = 0;
in_stream.open("Customers.dat");
string iDTemp;
string fntemp;
string lntemp;
float baltemp;
CustomerStatus stattemp;
int i = 0;
while (in_stream
    >> iDTemp
    >> fntemp
    >> lntemp
    >> baltemp
    >> stattemp)
{
    CCustomer temp(iDTemp, fntemp, lntemp, baltemp, stattemp);
    customers[i] = temp;
    i++;
}

红色错误行仅出现在>>下,该行在Stattemp之前。

CustomerStatus是一个看起来像这样的枚举:

enum CustomerStatus
{
INACTIVE,
ACTIVE,
};

ccustomer是一类。

我已经尽力解决这个问题并问了很多人,但是我似乎无法解决这个错误。

谢谢您的帮助。

编译器不知道如何将输入从文件转换为枚举类型,因此您需要某种方法来执行此操作。错误是由于它不知道如何将>>应用于所获得的数据。