我的电脑装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


{
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"


/**///////////////////////////////////////////////////////////////////////
//Construction/Destruction

/**///////////////////////////////////////////////////////////////////////

demo3::demo3()


{

}

demo3::~demo3()


{

}
ostream&operator<<(ostream&out,constdemo3&d)


{
out<<d.x<<endl;
returnout;
}
istream&operator>>(istream&in,demo3&d)


{
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>