我在这个程序中重载>>操作符,报出了如下错误:
Error 1 error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)
Error 2 3 IntelliSense: no operator ">>" matches these operands
operand types are: std::istream >> double
代码如下:
std::istream & operator>>(std::istream & is, Complex0 & c)
{
std::cout << "Please enter a: ";
is >> c.get_a();//这里报错
std::cout << "Please enter b: ";
is >> c.get_b();//这里报错
return is;
}
在类中声明如下:
friend std::istream & operator>>(std::istream & is, Complex0 & c);
求大神解释一下,并希望大神能够给出正确解决办法,感激不尽!!
碰到了一个短语c++操作符重载的问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答
悬赏问题
- ¥15 解决一个加好友限制问题 或者有好的方案
- ¥15 关于#java#的问题,请各位专家解答!
- ¥15 急matlab编程仿真二阶震荡系统
- ¥20 TEC-9的数据通路实验
- ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
- ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
- ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
- ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
- ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
- ¥30 求解达问题(有红包)