首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

>>重载警告解决方案

2012-03-04 
重载警告类原型:classfushu{doublex,ypublic:……friendistream&operator (istream&os,constfushu&a)

>>重载警告
类原型:
class   fushu
{
double   x,y;
public:
……
friend   istream&   operator> > (istream&os,const   fushu&a);
};
当有下列定义时有警告
istream&   operator> > (istream&is,const   fushu&a)
{
is> > a.x;
is> > a.y;
return   is;
}
'operator> > '   :   recursive   on   all   control   paths,   function   will   cause   runtime   stack   overflow
运行时无法输入就跳过了

[解决办法]
friend istream& operator> > (istream&os,const fushu&a);
==========
friend istream& operator> > (istream&os,fushu&a);

istream& operator> > (istream&is,const fushu&a)
=========
istream& operator> > (istream&is,fushu&a)
[解决办法]
呵呵...楼主想输入数据为什么还要把参数定为const呢?
[解决办法]
把两个const去掉.
[解决办法]
这个警告真是这段代码引起得?虽然const有错,但是也不该导致这种错误啊?
[解决办法]
呃,只看了错误信息就发表意见了,错误意见....
刚刚完整看了下,> > 应该被已经重载了
应该不会出现这个问题

应该只有const的问题

热点排行