I used fstream and opened and closed files. I did this so much I overloaded the function. I have many subroutines and need to constantly open and close the file. How can I do this?
You might want to take a step back. Why are you opening and closing the file so much. There's a lot of overhead to do that all the time. It is probably better to have it opened once and keep that handle available for later use.
If you still want to do what you are doing, then you need to give us a clearer understanding of what you are attempting to do. Writing an example to show this would probably help.