You are trying to write to an input stream using the
<< operator
which is not present (the base class
istream
does not have this operator):
ifstream collection(filename, std::fstream::in | std::fstream::out | std::fstream::app);
collection.close();
collection.open(filename, std::fstream::in | std::fstream::out | std::fstream::app);
collection<<ctr;
To perform input and output with one stream use the
fstream
class. But in your case it might be better to use a new output stream object for writing.