Do you want the open mode that was passed to the constructor or open member function? Or do you want to know dynamically whether the last operation was a read or a write?
Ultimately, you'd need to maintain a flag providing this information, which could be stored in the fstream object using xalloc/iword/pword, if you so choose. Though a separate variable would be simpler, in my opinion. Just wrap it up in another class and call it good. For example to remember the open mode:
The solution is the same: you need to save that information somewhere on every read or write. If you don't want to use a separate variable or wrap everything up in a class, then look up the xalloc/iword/pword member functions provided by ios_base.