Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

NicolasX

Pointer Preference

This topic is 5359 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

When do you, personally, like to use pointers? This isn''t a technical question it''s more of a question on your preference. Those aren''t bugs, they''re added features

Share this post


Link to post
Share on other sites
Advertisement
I use pointers when they are the best solution to the problem. I like to have structs where some data is seperate and some is common. I make a structure of common elements, and each struct/class can point to them, one change updates all the structures.

There are lots of uses like that. As references for data structure nodes, like trees and linked lists of course.

And when I need an array of un-defined size.

And when passing large objects, better to use a pointer, cuz otherwise the compiler will make a copy of the object itself.

Hope that''s the kind of stuff you are looking for.

Share this post


Link to post
Share on other sites
I used pointers when I was returning a value in the parameters passed to the function. Otherwise, I would use references or pass-by-value.

It''s nice to speak of C++ in the past tense

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!