注册 登录
编程论坛 C++教室

请问这错误是什么情况

a99875984 发布于 2012-03-27 18:20, 568 次点击
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class ostream &(__cdecl *)(class ostream &)' (or there is no acceptable conversion)
6 回复
#2
rjsp2012-03-28 08:12
ostream 的 o 是 out 的意思
>> 是 输入 的意思

#3
a998759842012-03-30 09:24
回复 2楼 rjsp
亲,能详细点吗?我不知道为什么会出现这种错误,出现了怎么解决
#4
BianChengNan2012-03-30 15:48
我估计你是重载运算符了吧
#5
蓝xuan2012-04-01 22:27
楼主能把全部代码贴出来吗??我这有个列子
如题,在做重载运算符<< 时,用到了操纵符,其中一个函数setfill()用错了,出现这样的提示.具体代码如下:

#include <iostream>

#include <iomanip>

using namespaec std ;

……

ostream& operator <<( ostream& os , const cal_date& date )
{
 int d,m,y ;
 date.get_date( d,m,y ) ;
 os <<
setfill(0) << setw(2) << d << " / "
    << setw(2) << m << " / "
    << setw(4) << y << endl ;
 return os ;
}

……

setfill()函数的参数是字符,也就是说,调用的时候括号里的字符要加上单引号,即

sefill('0')

经过修改后就不会出现这个错误了。
#6
Gzz2012-04-07 06:47
ostream 是输出,>>是输入
#7
wsgzg2012-04-09 22:43
将>>重载为全局函数,编译器就认识cin>>XXX;
1