【发布时间】:2014-05-13 19:50:52
【问题描述】:
我一直在为学校做一个项目,但遇到了一个问题。我试图避免对程序中的所有内容进行硬编码,而我的部分要求是使用 fstream。这是引发错误的原因。我使用 G++ 作为我的编译器。
void order::printToFile(string file)
{
ofstream output;
try
{
output.open(file, ios::app);
}
catch(...)
{
cerr << "An error has occurred";
}
output << this->info.orderID << setw(10) << this->info.type << setw(10) << this->info.quantity << setw(10) << this->info.zip << setw(10) << (this->info.shipCost + this->info.wholesale) << setw(10) << this->info.profit << endl << endl;
output.close();
}
它给了我以下错误:
没有匹配的函数可以调用'std::basic ofstream<char>::open( std::string&, const openmode&)'
有人可以帮我解决这个问题吗?谢谢
【问题讨论】:
标签: c++ c++11 fstream ofstream