我创建一个文件机智指定名称通过fstream的文件:函数写在C++
#include <fstream>
SYSTEMTIME systime;
GetSystemTime (&systime);
CString filename;
filename = specifyNameOfFile(timestamp, suffix); // call a method
std::ofstream fstream(filename, std::ios_base::app | std::ips_base::out);
我想创建像
void WriteToFile(unsigned int count, WORD hour, WORD minute, unsigned char result);
void WriteToFile(unsigned int count, WORD hour, WORD minute, unsigned char result)
{
fstream << count << " " << hour << " " << minute << " " << result << "\n";
}
的方法将采取输入的内容写入文件并应使用之前定义的fstream。
我尝试添加了fstream的给函数的输入,但没有奏效:
void WriteToFile(std::ofstream fstream, unsigned int count, WORD hour, WORD minute, unsigned char result);
其在VC\include\fstream(803) : cannot access private member declared in class 'std::basic_ios<_Elem, _Traits>'
了error C2248
。
有人可以提出一个解决方案,以显示我不明白该怎么办?
*您是如何尝试“将fstream添加到函数的输入”?你能告诉我们吗?你有什么问题?如果你还没有这样做,请[阅读关于如何提出好问题](http://stackoverflow.com/help/how-to-ask)。 –
@Someprogrammerdude修改我的问题以解决您提到的缺点。感谢您指出。希望现在这些都是排序的。 –