I'm not passing pointers to classes though. the serialization function just does like s << level; etc. It only serializes fields in the class. Thanks, Tyler Littlefield http://tds-solutions.net Twitter: sorressean On Jun 30, 2010, at 4:30 PM, qubit wrote: > what I'm trying to prevent with all these questions is the inadvertent > pointer shift that happens when you say B *bp = d; where d is of a type > derived from b, and there is multiple inheritance. > It's a nasty gotcha that may have been eliminated in more recent definitions > of C++, but I don't know so am warning you. > > Anyway, I also wanted to be sure you don't forget that things like virtual > pointers are embedded somewhere in the body of a class. These take up > space, and if you write sizeof(T) bytes then you will include the virtual > pointers, but if you are expecting just to get visible data then the > calculation will be off. > > Now if you don't do virtual functions, you'll have to think in another > direction. > Any closer? > > ----- Original Message ----- > From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx> > To: <programmingblind@xxxxxxxxxxxxx> > Sent: Wednesday, June 30, 2010 5:16 PM > Subject: Re: serialization, size errors... or something else. > > > What do you mean I'm passing it around as different types? Fwrite takes the > size of the block your writing, the number of blocks, and the file to write > to, as well as the block. so you supply 1 for the count, sizelf(T), and the > address of t. T is just the templated type. It looks something like: > template <class T> > void Write(const &T data) > > Thanks, > Tyler Littlefield > http://tds-solutions.net > Twitter: sorressean > > On Jun 30, 2010, at 4:13 PM, qubit wrote: > >> Ok, the plot thickens -- did you cast the address of the pointer to a >> char* >> to pass to fwrite? Maybe a dumb question but I'm just feeling this out. >> You have p being of some type T* and you say >> fwrite(fp, (char*)p, sizeof(T)); >> Is this done in a template function where you don't know the final type of >> T? >> What is T anyway? >> I'm just hoping some funny pointer arithmetic is not getting done on p >> because you are passing it around as different types. >> Any progress? >> --le >> >> >> ----- Original Message ----- >> From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx> >> To: <programmingblind@xxxxxxxxxxxxx> >> Sent: Wednesday, June 30, 2010 4:55 PM >> Subject: Re: serialization, size errors... or something else. >> >> >> Basically what I did was used a templated function to write, then I write >> the arg with fwrite, and use sizeof(T) to get the size. Reading does the >> same thing, I also overloaded operators << and >> to read and write. >> Thanks, >> Tyler Littlefield >> http://tds-solutions.net >> Twitter: sorressean >> >> On Jun 30, 2010, at 3:53 PM, qubit wrote: >> >>> without knowing a little about your serialization strategy, it's hard to >>> diagnose what might be wrong. >>> Do you do something similar to Boost, or do you have some other >>> algorithm? >>> --le >>> >>> ----- Original Message ----- >>> From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx> >>> To: <programmingblind@xxxxxxxxxxxxx> >>> Sent: Wednesday, June 30, 2010 4:02 PM >>> Subject: Re: serialization, size errors... or something else. >>> >>> >>> I do know I'm reading to much because I get a size excception. I'm not >>> sure >>> how to cut this down because the serialization works through an >>> inheritance >>> hierarchy.__________ >>> View the list's information and change your settings at >>> //www.freelists.org/list/programmingblind >>> >>> __________ >>> View the list's information and change your settings at >>> //www.freelists.org/list/programmingblind >>> >> >> __________ >> View the list's information and change your settings at >> //www.freelists.org/list/programmingblind >> >> __________ >> View the list's information and change your settings at >> //www.freelists.org/list/programmingblind >> > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind