From Seo Wiki - Search Engine Optimization and Programming Languages
|It has been suggested that this article or section be merged into fstream. (Discuss)|
The input stream may open a file in the constructor:
ifstream inf("input.dat", ifstream::in);
To close a stream, one uses the
The ifstream destructor will close the file cleanly as well. It is perfectly acceptable to allow the ifstream object to fall out of scope without calling
close. This is often a desirable style, as it simplifies the "clean up" process when an exception is thrown or an error is otherwise encountered.