没有运算符">>"与这些操作数匹配
No operator ">>" matches these operands
我在整个网站中都透彻了,找不到解决我独特问题的解决方案。
编译器不断提出"无操作员">>"与这些操作数匹配"。我尝试使用此代码时的消息:
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是一类。
我已经尽力解决这个问题并问了很多人,但是我似乎无法解决这个错误。
谢谢您的帮助。
编译器不知道如何将输入从文件转换为枚举类型,因此您需要某种方法来执行此操作。错误是由于它不知道如何将>>应用于所获得的数据。
相关文章:
- 控制允许动态运行c++的并发操作数
- 为什么C++逐位AND运算符在不同大小的操作数中表现为这样
- EASTL矢量<向量<int>>连续的
- 错误 C2679:二进制"<<":未找到采用类型 'std::string_view' 的右侧操作数的运算符(或者没有可接受的转换)
- C++ 带有向量的 IF 计算操作数
- 是否所有C++运算符都接受操作数?
- 一元*运算符的操作数是否期望一个 prvalue
- 与'operator='不匹配(操作数类型'String'且"void")
- 不正确的操作数类型 MSVC
- C2678 二进制 '==':未找到采用 'Card' 类型左操作数的运算符(或者没有可接受的转换)
- 错误:类型"double()"和"double()"的操作数无效到二进制&quo
- 我的运算符重载是否有效<<(流插入)左操作数不是 ostream
- 没有运算符"="与这些操作数匹配,JUCE 窗口演示应用程序
- 如果我在指针中使用 ++ 操作数,我的值就会出错
- 二进制表达式的操作数无效 - 使用 for 和迭代器
- C2679 二进制"<<":未找到采用右操作数类型的运算符
- CPP 运算符重载操作数位置 [] 与 ==
- int* 和 int[] 类型对二进制运算符 + 的操作数无效
- 错误:二进制'operator*' 'float'和'float[0]'类型的操作数无效
- 运算符'<'不能应用于类型 'string' 和 'string' 的操作数