I
Immortal Nephi
If I forget to put File.close() or File.close() is omitted in the
main function body, then do File’s destructor function takes care to
call File.close() automatically prior termination?
int main()
{
std::fstream File;
File.open( L"c:\\FileTest.txt", std::ios:
ut );
if( !File )
{
std::cerr << "Can't open file" << std::endl;
system( "pause" );
exit( true );
}
File << "Hello World!" << endl;
// File.close(); // is omitted?
return 0;
}
main function body, then do File’s destructor function takes care to
call File.close() automatically prior termination?
int main()
{
std::fstream File;
File.open( L"c:\\FileTest.txt", std::ios:
if( !File )
{
std::cerr << "Can't open file" << std::endl;
system( "pause" );
exit( true );
}
File << "Hello World!" << endl;
// File.close(); // is omitted?
return 0;
}