Sign in to follow this  

C++ Pointers

This topic is 4796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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++.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
Sign in to follow this