键和文件的 C++ 映射不起作用

C++ map of a key and file doesn't work

我想用 C++ 创建一个键和相应文件的映射。我使用了下面的剪接器,它在最后一行给出了平均异常 *m_jsTabFilesMap[key] << text;:

    std::map<std::string, std::ofstream*> m_jsTabFilesMap;
    std::string text = "hello all";
    std::string key = "a";
    *m_jsTabFilesMap[key] << text;

std::ofstream 的复制构造函数被明确删除。您必须通过指针或其他方式存储流,如果您希望它们在地图中,则不会尝试复制流对象。