Sign in to follow this  
Adam Gleason

C++ Pointers

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this