pointer.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Umangengineer
    New Member
    • Mar 2008
    • 4

    pointer.

    i have a doubt about if we make a pointer for some variable then it helps us to access it quickly as it tells us adress of it in memory, but there would be some address given to ponter function also in memory...
    so system will first have to find it location and then it will proceed t that variable..
    so how it will increase speed...
    i need a solid answer......
  • DumRat
    New Member
    • Mar 2007
    • 93

    #2
    The whole point of pointers is not to work with the actual data, but work with a proxy for that data. As in the parliamentary system. :)
    But you can access the actual data anytime you need via a pointer to that data.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by Umangengineer
      i have a doubt about if we make a pointer for some variable then it helps us to access it quickly as it tells us adress of it in memory, but there would be some address given to ponter function also in memory...
      so system will first have to find it location and then it will proceed t that variable..
      so how it will increase speed...
      i need a solid answer......
      Well, the address of something doesn't need to be searched for, it is a O(1)
      operation and is as fast as it can be. Dereferencing a pointer is an indirect
      operation and can take up a bit more cpu cycles than dereferencing the
      object itself though. The same holds for pointers to functions

      kind regards,

      Jos

      Comment

      Working...