用VC6.0遇到的一个问题

我的电脑装vs2008总是报错,不得已装了个VC6 sp6暂时先用用,发现使用重载输入输出运算符时有问题

demo3.h

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->#include<iostream.h>
classdemo3
ExpandedBlockStart.gifContractedBlock.gif
{
public:
demo3();
virtual~demo3();
friendostream
&operator<<(ostream&out,constdemo3&d);
friendistream
&operator>>(istream&in,demo3&d);
private:
intx;

}
;

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->
#include
"stdafx.h"
#include
"demo3.h"

ExpandedBlockStart.gifContractedBlock.gif
/**///////////////////////////////////////////////////////////////////////
//Construction/Destruction
ExpandedBlockStart.gifContractedBlock.gif
/**///////////////////////////////////////////////////////////////////////

demo3::demo3()
ExpandedBlockStart.gifContractedBlock.gif
{

}


demo3::
~demo3()
ExpandedBlockStart.gifContractedBlock.gif
{

}

ostream
&operator<<(ostream&out,constdemo3&d)
ExpandedBlockStart.gifContractedBlock.gif
{
out<<d.x<<endl;
returnout;
}

istream
&operator>>(istream&in,demo3&d)
ExpandedBlockStart.gifContractedBlock.gif
{
returnin;
}

编译后报错:

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->errorC2248:'x':cannotaccessprivatememberdeclaredinclass'demo3'

查了下网上的资料,说是vc6的bug,而在vc8中就没问题,暂时的解决办法是将#include<iostream>改为#include<iostream.h>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值