The error may be depending on how you're using the fstream object, because if there were a problem with the std library, it would have been corrected a long time ago.
If the error is saying it cannot access the private data member then you should try making it a public variable to see if that will make a difference. If it absolutely needs to be private, then consider making a friend class for whatever is calling it.