Kobe___Bryant
2016-05-04 11:08碰到了一个短语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条回答
为你推荐
- 另一种使“if语句”简短的方法
- php
- 3个回答
- 从短语中删除单词,并在单词之间只留一个空格
- regex
- php
- 4个回答
- 从字符串php捕获日期短语
- php
- 4个回答
- Regexp在字符串PHP中搜索精确短语
- regex
- php
- 1个回答
- PHP用短语替换发誓的单词
- words
- string
- echo
- php
- 4个回答
换一换