+ 1

Does a file will be global if its objected is created globally but opened in main or any other function?

#include <fstream> using namespace std; ifstream fin; int main(){ fin.open("test.txt",ios::in|ios::binary); .... } In the above code if the file opened is global (can it be use globally or not).

12th Aug 2017, 9:47 AM
Shubham chauhan
Shubham chauhan - avatar
1 Resposta
0
Yes. It will be accessable file fin (P.S. don't forget to close it)
15th Aug 2017, 11:33 PM
Michal Pácal
Michal Pácal - avatar