我在这个程序中重载>>操作符,报出了如下错误:
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 提建议
- 追加酬金
- 关注问题
- 邀请回答
-