On 2007-08-29 00:00, greg wrote:
Hi All,
Could anyone tell me when one should use objects and when pointers?
Pointers and objects are kind of orthogonal concepts, since pointers
points to objects (static or not), so you can't really have pointers
without objects (if you consider the built-in types to be objects).
Are you perhaps referring to when to pass parameters as pointers or when
to pass by value. My answer should be, use references when you can, by
value where it makes sense and pointers only when you have to.
Pointers are very powerful but they are also the source of many errors
and much can be done without them in safer ways, which is generally
preferable. Learn the differences between these methods and it's often
quite clear which is the best to use.
--
Erik Wikström