i'm using microsoft only because my course staff required this . and course staff are under budget so i'm asking you people
hash_map<int,int> H, S;
for( .. ;... ;... )
H.insert(....);
ofstream out("tmp",ios::binary);
out.write((char*)&H,sizeof(H)); <===== write H to file
out.flush();
ifstream in("tmp",ios::binary);
in.read((cahr*)&S,sizeof(H)); <===== read H from file into S
after this H.size()==S.size() and data are equal
but destructor of S naturally doesn't work
please read bellow for further info
Kohn Emil Dan wrote:
Hi,From the error message you receive, it seems that you are using MicrosoftVisual C++, (so some haifux guys might rightfully ask you: "And your linux question is...";-) with a debug version of the runtime library and you are messing up the dynamic memory heap.As far as I know, the STL implementation which comes with MSVC++ does not include a hash_map, because hash_map is not part of STL, according to the C++ standard, so it seems that you are using a different implemtation of STL. So my questions are:1) What STL implementation are you using? 2) Can you post a minimal code snippet which exposes the problem?Emil On Wed, 6 Jul 2005, yakoub abaya wrote:i want to write an STL object to a file using binary stream i have ( hash_map H,S ; ) i initielizing H using class interfase . then write H to file , read from the same file into S after this , S and H have the same data and H.size==S.size but at the end of the program i get assertion faillure: _BLOCK_TYPE_IS_VALID(phead->nBlockUse) i asume the problem is that S was writen-to without using its class interface and that interferes with its destruction . is this the case ? i thought about using the C'tor of S ..but couldn't see how , if only there was a method of hash_map that returns a fixed array of data that can be used later to construct a new object like in the string case . how do i get this done ? i need to write a large STL object to file so that program memory usage wouldn't be too large ..--------------------------------------------------------------------------Haifa Linux Club Mailing List (http://www.haifux.org) To unsub send an empty message to [EMAIL PROTECTED]--------------------------------------------------------------------------Haifa Linux Club Mailing List (http://www.haifux.org) To unsub send an empty message to [EMAIL PROTECTED]
-------------------------------------------------------------------------- Haifa Linux Club Mailing List (http://www.haifux.org) To unsub send an empty message to [EMAIL PROTECTED]
