Afficher un message
Vieux 15/10/2007, 20h31   #2
red floyd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Why use object pointers rather than objects?

krishna.kishore.0987@gmail.com wrote:
> Why are always object pointers used? (i.e., ObjectType *objPointer)
> what are the advantages of using object pointers Vs objects
> (ObjectType obj)


Polymorhpism and slicing.

> one advantage I see is passing them across methods, but is this purely
> presentation issue (use 'objPointer' rather than '&obj') or are there
> some performance affects?


Now you're talking about references instead of copied objects. The
advantage is that a reference parameter always refers to a valid object
(modulo UB in the caller, of course).


  Réponse avec citation
 
Page generated in 0,04913 seconds with 9 queries