🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Pointers: When to use them and when to not?

Started by
0 comments, last by Spearhawk 22 years, 10 months ago
I''m in the middle of the chapter about pointers in Sams Teach Yourself C++ in 21 days. And, well my question is pretty much what''s in the topic. Pointers seems to be very much like variables only that the memory are taken from another part. So when should I use them and when should I not? I just finished my first game, a brick clone made in the Windows Consol. To do it I didn''t use any pointers and it seems to run just fine. Should I have used pointers?
Advertisement
Yes, you''ll use pointers a lot, but that doesn''t mean you''ll always use them (well, I seem to almost always use them in my programs...). They''re useful for resource sharing (having a pointer to an object rather than 400 copies of it for each thing that needs to use it), dynamic memory allocation, passing large parameters or objects that you want modified by the function you pass them to, et cetera.

[Resist Windows XP''s Invasive Production Activation Technology!]

This topic is closed to new replies.

Advertisement