My proposal is the take the opening and closing out of the constructor and destructor, respectively. Then add those to functions named openFile(), and closeFile(). This would allow the user to read multiple files with only one IReadFile, e.g.:
Code: Select all
IReadFile* myFile;
myFile->openFile("test.txt");
myFile->closeFile();
myFile->openFile("test2.txt");
myFile->closeFile();
Code: Select all
IReadFile* myFile = new IReadFile("test.txt");
IReadFile* myFile2 = new IReadFile("test2.txt");
... etc ...