#include
#include
#include
#include
class InorOut
{
public:
double In;
double Out;
char Date[9];
void Display();
};
void InorOut::Display()
{
cout<
}
void Show(InorOut *CurUsrInc)
{
InorOut *AllInc = new InorOut; //new instance
fstream f("0000.sav",ios::binary|ios::in); /////////////////////open method
if(!f)
{
cerr<<"文件不能打开"<
}
f.seekg(0,ios::end);
long posEnd=f.tellg();
f.seekg(0,ios::beg);
do
{
f.read((char*)AllInc,sizeof(InorOut)); //no &
}while(f.tellg()!=posEnd);
cout<<"After Reading"<
delete AllInc;//release instance
}
void main()
{
InorOut *CurUsrInc;
CurUsrInc = new InorOut; //new instance
fstream iof("0000.sav",ios::binary|ios::out); /////////write method
iof.seekp(0,ios::end);
if(!iof)
cerr<<"\n\n文件建立失败"<
CurUsrInc->Out=0;
strcpy(CurUsrInc->Date, "01/01/09");
iof.write((char*)CurUsrInc,sizeof(InorOut)); //no &
iof.close();
Show(CurUsrInc);
delete CurUsrInc;//release instance
}
我在我电脑上测试了。编译没问题,连接没问题。
那是不是你的VC问题?