Pointer Preference

Started by
1 comment, last by NicolasX 20 years, 4 months ago
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
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.
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

This topic is closed to new replies.

Advertisement