if i have a class object w/ 50 nodes attached (each one a pointer to another), and save it using write(), how would i load back in that object? and how would i know the size of it if i load it back in again?
if i have a class object w/ 50 nodes attached (each one a pointer to another), and save it using write(), how would i load back in that object? and how would i know the size of it if i load it back in again?
Well, if you just did a write, all you would do is write to disk the logical address of the first data member -- in other words, a useless number.
You need to do a custom read/write. Create a format for your data, and use it.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
so your saying that i would need to write each node individually to the file?
actually... what IM really asking is... if i have a pointer to an object in my class and use the new keyword w/ it... and save it using write... does the data the pointer points to carry over to the file so that i can read it if i know the filesize (it could be NULL)?
You really need to post more code so we can see what you're actually doing wrong.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
im not doing anything wrong... my code is fine as it is... but im asking a question on what im GOING to program. i wanna store linked lists in a file... im wondering how i would go about doing that.
The reason Salem asked for code is because that does not make things very clear...actually... what IM really asking is... if i have a pointer to an object in my class and use the new keyword w/ it... and save it using write... does the data the pointer points to carry over to the file so that i can read it if i know the filesize (it could be NULL)?
What kind of data do you mean? It depends how you write it to the file...You could write the length of the file to the top and then whatever you saved comes after it.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared