I have some problems, I'm getting these errors (marked in the code):
Why?
#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
}
The cerr object in C++ is an object of class ostream . It is associated with the standard C error output stream stderr . The cerr object is ensured to be initialized during or before the first time an object of type ios_base::Init is constructed.
cerr – Standard Error Stream Object in C++ Standard error stream (cerr): cerr is the standard error stream which is used to output the errors. It is an instance of the ostream class.
You must include iostream
in order to use cerr
.
See http://en.cppreference.com/w/cpp/io/basic_ostream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With