在结构中使用fstream,错误
Using fstream in struct, errors
我正在尝试初始化结构中的文件输出流。应该创建的文件有一个我想在主函数中定义的名称,即:
#include <iostream>
#include <fstream>
struct str {
std::ofstream fs;
};
int main() {
str G;
G.fs("hello.txt",std::ios::app);
}
这让我:错误:对"(std::fstream{aka std::basic_stream})(const char[10],const openmode&)"|的调用不匹配
如何做对?
int main() {
str G;
G.fs.open("hello.txt",std::ios::app);
}
相关文章:
- 为什么 fstream 在打开带有格式的文件时会导致分段错误?
- 为什么当我在 std::string 中打开文件名的 fstream 时出现"no matching function"错误?
- C++ 错误检查 fstream open() 命令和一般字符串流错误处理
- 变量 std::fstream 文件具有初始值设定项,但类型不完整 编译错误
- std::fstream 已使用,但编译器抛出错误
- 为什么错误"permission denied","id returned 1 exit status"仅在 IM 使用 C++ 中的头文件 fstream 时才出现
- fstream.h 中的 STL 命名空间错误与 qmake/make.
- 为什么我的简单C++程序使用队列和 fstream 错误到无效指针
- C Fstream字符串组合错误
- Fstream中的写功能将在Windows 10上引起错误
- fstream错误无法在C 中创建或打开文件
- CMD窗口停止工作,文本文件使用fstream读取错误
- 在结构中使用fstream,错误
- Ubuntu 13.10 中的 GCC iostream fstream 错误
- 如何在将 fstream 数据写入磁盘时检测致命错误
- 编译器C++中的 fstream 错误
- 在c++中使用同一个fstream对象进行读写时,是否有任何导致错误的特性
- fstream 错误,"streambuf"当我尝试编译和运行时
- c++中的fstream错误
- 使用Cygwin编译时出现fstream错误