我有一些問題,我得到這些錯誤(標記代碼):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