std::map can't possibly work, because std::map requires its data type to be Assignable, which std::ofstream isn't. In the alternative, the data type must be a pointer to ofstream -- either a raw pointer or a smart pointer.
Here is how I would do it, using C++11 features:
#include
#include
and the 2nd verse, in C++03:
#include
#include