Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!lll-lcc!pyramid!athertn!thanh From: thanh@athertn.Atherton.COM (Thanh Diec) Newsgroups: comp.lang.c++ Subject: Objectifying contents read in from disk Message-ID: <7316@athertn.Atherton.COM> Date: 24 Jul 89 01:26:12 GMT Reply-To: thanh@athertn.Atherton.COM (Thanh Diec) Distribution: usa Organization: Atherton Technology, Sunnyvale, CA Lines: 44 After objects are written out to disk, and then read back in again, possibly by a different program, what does the reader need to do to set the content read in to behave correctly as objects? For example, the runtime _vptr's in the writer program are going to be different from the reader's, even though both programs include the same ".h". Writer: // write out an array of 1024 objects write(fd, &object_array[0], sizeof(class1) * 1024); Reader: read(fd, buf, sizeof(class1) * 1024); class1 *p1 = (class1 *)buf; // buf is not ready to used as objects yet, must set runtime values // such as _vptr's for (idx = 0; idx < 1024; idx++) { // ??? what to here without doing a second copy into a correctly // initialized dummy object. dummy_obj->member1 = (p1+idx)->member1; dummy_obj->member2 = (p1+idx)->member2; dummy_obj->member3 = (p1+idx)->member3; } Thanks in advance, Thanh Diec Atherton Technology (408)734-9822 thanh@atherton.com {hpda,sun,decwrl}!athertn!thanh