Kobe___Bryant 2016-05-04 11:08 采纳率: 0%
浏览 1676

碰到了一个短语c++操作符重载的问题

我在这个程序中重载>>操作符,报出了如下错误:
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);
求大神解释一下,并希望大神能够给出正确解决办法,感激不尽!!

  • 写回答

3条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!