Hi,
I am trying to work out if I need to call close on a fstream object if the intial open failed.
i.e.
std::fstream strm;
strm.open( "filename" );
if( ! strm.fail() )
{
// Do something
strm.close(); // [1]
}
strm.close(); // [2]
Where should close be called here - should it always be called [2] or only if the open succeeds[1]?
I may be going over the top here, but coming from the Windows API way of typically doing this I have CloseHandle( ... ); embedded in my mind :-)