do I need to close a std::fstream? [duplicate]
Possible Duplicate: Do I need to manually close a ifstream? Do I need to call fstream.close() or is fstream a proper RAII object that closes the stream on destruction? I have a local std::ofstream object inside a method. Can I assume that the file is always closed after exiting this method without calling close? I could not find documentation of the destructor. I think the previous answers are misleading. fstream is a proper RAII object, it does close automatically at the end of the scope, and there is absolutely no need whatsoever to call close manually when closing at the end of the scope is