#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
class A
{
public:
A(int=0,int=0);
friend ostream& operator <<(ostream&, A&);
private:
int a, b;
};
A::A(int a1, int a2)
{
a = a1; b = a2;
}
ostream& operator <<(ostream& s, A &a)
{
return s << a.a << ' ' << a.b;
}
main()
{
A obj(10,100), obj1;
// von fstream kann zugleich gelesen und
// geschrieben werden!!
fstream aFile;
aFile.open("out.bin", ios::in | ios::out);
streampos p = aFile.tellp();
aFile.write((char*)&obj, sizeof(A));
aFile.seekg(p);
aFile.read((char*)&obj1, sizeof(A));
cout << obj1 << endl;
aFile.close();
}