Afficher un message
Vieux 15/10/2007, 23h46   #5
Krishna
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Why use object pointers rather than objects?

On Oct 15, 2:14 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> krishna.kishore.0...@gmail.com wrote:
> > Why are always object pointers used? (i.e., ObjectType *objPointer)

>
> Always? I don't always use them. In fact, I seldom use them.
> This is a very typical example of where I don't use them:
>
> std::string s = "hello";
>
> No pointer there.
>
> > 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?

>
> If you pass an object by value then a copy will most probably be made,
> which will often be less efficient than passing by reference or by
> pointer. Also there's the slicing problem if inheritance is involved.


Hi Guys,
Thanks for the replies. When I was punching 'always' I was stuck in
the world of GUI, I see pointers being used for GUI objects, 'always'
Thanks again,
Krishna

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