How do I persist a C++ pointer?
-
I want to save a linked list to an Access97 database. How do I do it in ADO.Net? The following code doesn't compile/work.. CNode* pNode; pDataRow->Item["ptrNode"] = &pNode; I don't know what this compile error means "error C2102: '&' requires l-value" Also Access97 has a "number" data type, can it store a pointer??? Can anyone help???
-
I want to save a linked list to an Access97 database. How do I do it in ADO.Net? The following code doesn't compile/work.. CNode* pNode; pDataRow->Item["ptrNode"] = &pNode; I don't know what this compile error means "error C2102: '&' requires l-value" Also Access97 has a "number" data type, can it store a pointer??? Can anyone help???
Saving a pointer to a node might not be such a good idea. The pointer is a physical address and that can change the next time the application is run. In a .NET application that can change while the application is running.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
Saving a pointer to a node might not be such a good idea. The pointer is a physical address and that can change the next time the application is run. In a .NET application that can change while the application is running.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
ooh yes, didn't think of that, thanks. So do you know how to persist/save a linked list to Access97 ???
-
You can't save a linked list to a database. Either you have to serialize the entire list (which you probably have to do yourself), or save each item to a separate record. --- b { font-weight: normal; }
Guffa, Are you saying that if the entire linked list is serialised the system will maintain the links between the nodes, and I don't need to code/worry about it? Do you know a code example of of a serialised linked list??? I was trying to save each node as a distinct record like your second suggestion. But how do you save the links using this option?
-
Guffa, Are you saying that if the entire linked list is serialised the system will maintain the links between the nodes, and I don't need to code/worry about it? Do you know a code example of of a serialised linked list??? I was trying to save each node as a distinct record like your second suggestion. But how do you save the links using this option?
dragon_n_me wrote:
Are you saying that if the entire linked list is serialised the system will maintain the links between the nodes, and I don't need to code/worry about it?
Yes, and no. References can't be maintained in any other form than a reference. If the list is serialized it will store the information about how the items are linked, and recreate the references when it's deserialized.
Do you know a code example of of a serialised linked list???
No.
I was trying to save each node as a distinct record like your second suggestion. But how do you save the links using this option?
You can't save references, you have to save some information that you can use to recreate the references. --- b { font-weight: normal; }
-
ooh yes, didn't think of that, thanks. So do you know how to persist/save a linked list to Access97 ???
To serialize, iterate over the linked list. Maintain a counter while you are iterating. Save each list item in the database along with the counter. To deserialize, query the database for your list information, sorted by counter. Iterate over the list information, appending each record as a node to the end of your list. -- modified at 23:57 Monday 10th July, 2006