Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. How do I persist a C++ pointer?

How do I persist a C++ pointer?

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestioncsharpc++database
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dragon52
    wrote on last edited by
    #1

    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???

    C 1 Reply Last reply
    0
    • D dragon52

      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???

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • C Colin Angus Mackay

        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

        D Offline
        D Offline
        dragon52
        wrote on last edited by
        #3

        ooh yes, didn't think of that, thanks. So do you know how to persist/save a linked list to Access97 ???

        G B 2 Replies Last reply
        0
        • D dragon52

          ooh yes, didn't think of that, thanks. So do you know how to persist/save a linked list to Access97 ???

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          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; }

          D 1 Reply Last reply
          0
          • G Guffa

            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; }

            D Offline
            D Offline
            dragon52
            wrote on last edited by
            #5

            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?

            G 1 Reply Last reply
            0
            • D dragon52

              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?

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              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; }

              1 Reply Last reply
              0
              • D dragon52

                ooh yes, didn't think of that, thanks. So do you know how to persist/save a linked list to Access97 ???

                B Offline
                B Offline
                Brian P Bailey
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups