Ofstream 拒绝带有参数的输入
Ofstream rejects input with parameters
我正在为学校项目工作,我必须在 txt 文件中写入一些行。没有什么不寻常的,但问题来了。当我尝试通过函数中的参数输入输出文件名时,它说没有匹配的函数可供调用。让我向您展示我的代码:
bool save(vector<City*> city, string output){
ofstream dat(output); // ... here comes the problem
}
如果有人知道这里有什么问题以及如何使其工作,我将非常高兴。谢谢
您必须启用-std=c++11
编译器选项,或使用ofstream dat(output.c_str());
请参阅可用std::ofstream
结构器的参考文档。
相关文章:
- 将输入参数作为右值引用传递?
- 是否可以在命令行中将输入参数传递给可执行文件
- C++基于输入参数的动态代码生成
- 我想知道为什么"std::unique_ptr<int> foo(新 int)"是合法的,因为"std::<int>unique_ptr"要求输入参数类型应该是"int"?
- 如何使用输入参数作为文件的传递?
- 在函数中使用运算符重载,在 c++ 中使用 const 类型输入参数
- 提供变量作为 MATLAB 系统命令的输入参数,以便C++可执行文件
- 函数的函数无法识别输入参数
- 当迭代器(输入参数)通常不是constexpr时,constexpr算法真的有用吗
- 如何将一个使用参数包和typename的类作为函数(c++)的输入参数
- CvMat:输入参数的大小不匹配
- 在什么情况下,使用'const T*'输入参数比'const T&'更可取?
- std::具有两个输入参数的矢量构造函数
- GoogleMock:如何根据另一个输入参数设置ArgReferee?
- 模板化函数以从输入参数推断返回类型 stl-container
- GoogleMock:如何验证输入参数的调用次数?
- 当我将 char 数组发送到输入参数为字符串的函数时会发生什么?
- 应该接受不同输入参数的纯虚函数 - 应该如何实现
- C++主函数的输入参数
- STD :: Atomic_fetch为什么将指针作为其输入参数