Originally Posted by
laserlight
Show this part of your code.
There isn't really much to show... but:
Code:
// first time
FILEIOASCII File( Filename, IO_READ );
// second time
FILEIOASCII File( Filename, IO_WRITE );
Also, did you disable the the copy constructor and copy assignment operator of FILEIOASCII? Did you implement the destructor correctly? Why are you storing pointers to std::ifstream and std:
fstream in the first place?
I tried changing the pointers to non-pointers and the problem still happened. There are no other pointers in the class so I don't think a copy constructor/copy assignment operator would be the cause.
Just to clear things up, here's the rest of the code for that class:
Code:
class FILEIOASCII
{
public:
FILEIOASCII( std::string& Filename, __int8 OpenType, bool Append = false );
~FILEIOASCII();
template < typename T > bool Action( T& Data );
bool IsEOF();
private:
std::ifstream iFile;
std::ofstream oFile;
__int8 OpenType;
};
template < typename T > bool FILEIOASCII::Action( T& Data )
{
if ( OpenType == IO_READ )
{
iFile >> Data;
return true;
}
else if ( OpenType == IO_WRITE )
{
oFile << Data;
oFile << ' ';
return true;
}
WNG( "File has incorrect open type." );
return false;
};
FILEIOASCII::~FILEIOASCII()
{
if ( OpenType == IO_READ )
iFile.close();
else if ( OpenType == IO_WRITE )
oFile.close();
else
WNG( "File has incorrect open type." );
};
bool FILEIOASCII::IsEOF()
{
return OpenType == IO_READ ? iFile.eof() : oFile.eof();
};