C++ Pointers

Started by
1 comment, last by porthios 19 years, 4 months ago
ok i got a question about pointers. i think i know what they are but i am not sure. ok to me a pointer is a variable that holds the adress for a spot of memory right? and where would that come in handy in game programming. i havnt got to game programming stuff yet becuz i am still learning c++.
-
+click here to veiw sig
+My Myspace
+[email=webmaster@hideoutgear.com]Email Me[/email]
Advertisement
The biggest 2 uses for pointers are 1) dynamically allocated memory and 2) referencing other objects.

1) Whenever you need to allocate memory using new or malloc (or some similar function), you'll need to use pointers.

2) Whenever objects need to refer to other objects (such as a room refering to which other rooms it is connected to), pointers are often the most straightforward way to go. They are actually used extensively in general purpose programming for many different data structures, such as linked lists or trees, which you can look up on Google for more info.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
Try creating all the objects in a game on the heap (without using pointers and new). Your answer lies there (plus its just convenient to use pointers sometimes)

This topic is closed to new replies.

Advertisement