I want to make a FileIO class which will provide some methods like write or read. Also I want to hide the implementation of FileIO (currently, it just derives from std::fstream). The problem is that std::fstream could throw some exceptions but I don't want my FileIO class to throw std::fstream exceptions, I want to throw my own (e.g. FileIO::SomethingBadHappened). Is there an elegant way to do this?
My solution is to just rewrite every method of std::fstream with an additional try/catch block.
EDIT: FileIO class is just an example. I'm looking for a general solution for wrapping an arbitrary class.
fstreamdirectly? It's there to be used, not to be wrapped.exceptions). Using inheritance is problematic here.fstreamalready does... are you under the impression that it does not use the Windows API under... Windows?fstreamsolved this problem already, what problem are you trying to solve exactly?