Skip to main content
gamedev.net
🔒 Locked

Pointers...

Started by BioSquirrel 2 replies 400+ views
Original Post
BioSquirrel
BioSquirrel
I understand what they do, but what is the point of them (no pun intended). Why would I want to use one?
Qw3r7yU10p!
Qw3r7yU10p!
To be able to access data from various parts of your program you can pass around pointers to the data (rather than copying it into functions where you need it). Also if you dynamically allocate data you will be given a pointer to it to look after. Once you''re finished with that data you need to deallocate the data (which is why you have to keep track of the pointer)
TheShadow
TheShadow
Think about this if you have a variable where you allocate a bsp map (quake map file type) everytime you use it if you dont use pointers you are making copies of it in memory and wasting it... but if you use pointers you always use the same instance that is saved in memory,.
Mecha Engineer (Making Real Humanoid Suits)
DerekSaw
DerekSaw
quote:
Original post by BioSquirrel
I understand what they do, but what is the point of them (no pun intended). Why would I want to use one?

Sometimes, we need a whole different level of indirection to have things work out easily. Try doing a dynamic link-list without using pointers.


[edited by - DerekSaw on March 21, 2003 11:33:27 PM]
"after many years of singularity, i'm still searching n the event horizon" o

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.