   Pointers
  I'm having trouble understanding the concept of pointers (as I'm sure many do).Is their only purpose memory management?   
  I do believe so. Now, don't really take my word for it. I still don't fully understand these little guys myself. They are very useful though. Pointers can be described like this:(In my own opinion) A useful segment in code used to store data for later use. I hope that clears your understanding. But I could be wrong, that is more of a guess.;  They are useful for implementing reseatable reference semantics.   ;  Pointers are Very useful; if used at the right times but can quickly turn otherwise good code into speggehti(sp?) code.One example of good pointer use is page buffering (you know using two images for the display, one gets updated while the other gets rendered).In the early days, they used to copy all of the backbuffer's data to the front buffer and that, as you know, took up alot of memory and processing.  Then some one came up with the Idea of using a pointer, instead of doing all that copying just change the pointer (which is only a few bytes to [at the time] huge kilo bytes) .  I don't know when pointers were 'invented' but Id guess sometime around then.As for memory management, they can be very useful.  One method would be to have your memory manager object keep somesorta list of all things that need deletion etc with a pointer, and this saves memory with minimal overhead cost.  Exactly what memory management systems strive to do.   ;  Just Ask Binky!.   ;  Pointers allow us to design good data-structures and algorithms. :)Pointers also allow us to be more effecient with data as we can pass pointers to large datatypes instead of the datatypes themselves.Pointers to functions allow us to design event-driven callbacks.Void pointers (void*) allow us to be generic.Pointers pretty much allow us programmers to do everything worthwhile. :)   ;Quote:Original post by luke2In the early days, they used to copy all of the backbuffer's data to the front buffer and that, as you know, took up alot of memory and processing.  Then some one came up with the Idea of using a pointer, instead of doing all that copying just change the pointer (which is only a few bytes to [at the time] huge kilo bytes) .  I don't know when pointers were 'invented' but Id guess sometime around then.You might find in fact they go back to the first stored program computer.A pointer is a memory address.  When it comes down to what the CPU is doing, whenever it need to fetch or store a value in memory, it has to use some sort of pointer.  The address of a value in memory (RAM) is either an absolute value, a value stored in a register, or the sum of two or more of the above.  Just like any other value you can load and store, you can perform arithmetic on memory addresses.The C language was developed as an aid to develop the Unix operating system in a portable fashion in the late 1960s.  Programming an operating system requires programming the CPU very close to the metal, including individual memory loads and stores.  An abstraction of the manipulation of these memory addresses, or pointers, was an absolute necessity for an OS-development language, and C was no exception.  The C++ language provides everything the C language provides, and then some.So you see, pointers were invented many many years before anyone though of backbuffers.  It really helps to just think of them as variables holding memory addresses of other variables.   ;  I understand that pointers are used to hold the memory address of variables and such...But I fail to see how this is useful in programming with the exception of memory managementAs I can allocate and de-allocate memory at willI don't see what pointers can do that variables can't   ;Quote:Original post by BrianMattJohnsonPointers allow us to design good data-structures and algorithms. :)Pointers also allow us to be more effecient with data as we can pass pointers to large datatypes instead of the datatypes themselves.Pointers to functions allow us to design event-driven callbacks.Void pointers (void*) allow us to be generic.Pointers pretty much allow us programmers to do everything worthwhile. :)There you go.   ;Well, for example, with pointers you can allocate an array with a size you don't know before hands. That is impossible with static sized array.Or perhaps, you need a linked list for keeping track of game objects, because you don't know how many objects there will ever be. Linked list is based on pointers, every member of the linked list has a pointer to the next object in the list (and usually to the previous elements). This is something you cannot accomplish without pointers.Pointers alone, they only point to some part of memory. That's all and end of it. You never needed to "point" to anywhere?Practically, an array with static size should be reconsidered if there is a possibility that you'll need a bigger array some day (and then you realize that eventually you'll end up increasing the size to infinity and thus are wasting memory).I wouldn't say that pointers are about memory management. More like, they are needed to handle memory.   