beeoproblem, 24 days ago E.g. { FileReader theFile = FileReader("thing.txt"); // this opens the file // do stuff } // The file is closed now When theFile is initialized it opens thing.txt. When theFile falls out of scope, for any reason, its destructor is called which then closes the file.
E.g. { FileReader theFile = FileReader("thing.txt"); // this opens the file
// do stuff }
// The file is closed now
When theFile is initialized it opens thing.txt. When theFile falls out of scope, for any reason, its destructor is called which then closes the file.