我有一些问题,我得到这些错误(标记代码):CERR是不确定的
- 标识符“CERR”未定义
- 没有运营商“< <”匹配这些操作数
为什么?
#include "basic.h"
#include <fstream>
using namespace std;
int main()
{
ofstream output("output.txt",ios::out);
if (output == NULL)
{
cerr << "File cannot be opened" << endl; // first error here
return 1;
}
output << "Opening of basic account with a 100 Pound deposit: "
<< endl;
Basic myBasic (100);
output << myBasic << endl; // second error here
}
不错,但国际海事组织设置fstream在出现错误的情况下抛出异常更好。 – 2010-11-01 13:44:36