Is there a way in C++ to close all open streams without directly referencing the stream:
e.g. filestream.close();
I ask because I have a program where one of my file streams in not in scope when I call exit(-1) to terminate my program. The file stream is a member of a class and I would like to avoid having to pass around another reference to the class. Anyway to do something like:
cin:streams.close();
???
Lastly, does it even matter if I close it, or will it get closed by destructors when I call exit(-1)? Thanks
Question
ProChefChad
Is there a way in C++ to close all open streams without directly referencing the stream:
e.g. filestream.close();
I ask because I have a program where one of my file streams in not in scope when I call exit(-1) to terminate my program. The file stream is a member of a class and I would like to avoid having to pass around another reference to the class. Anyway to do something like:
cin:streams.close();
???
Lastly, does it even matter if I close it, or will it get closed by destructors when I call exit(-1)? Thanks
Link to comment
Share on other sites
9 answers to this question
Recommended Posts