#include <stdexcept>
...
#include "duoas-binary-io.hpp"
usingnamespace little_endian_io;
...
void v::write()
{
ofstream f( "ivan.a", ios::binary );
if (!f) throw std::runtime_error( "Could not open file \"ivan.a\"!" ); // don't halt your program, just complain
for (unsigned n = 0; n < a.size(); n++)
write_word( f, a[ n ] );
f.close();
}
to kbw:
Class can be write in binary file like that: fp.write((char*)this,sizeof(this));
and can be read like that fp.write((char*)this,sizeof(this));
but it,s work only with static data. If it's dinamic like vector really i must use example of Duoas, but then i must write and the size of the vector, to know after that how exactly records i have in the fail and read it. Can some one give me idea how read vector exclude to write it size ih the fail