Afficher un message
Vieux 15/10/2007, 22h14   #4
Juha Nieminen
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)


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.
  Réponse avec citation
 
Page generated in 0,04930 seconds with 9 queries