"Le Géant Vert" <_> wrote...
>
> "Gene Wirchenko" <> a écrit dans le
> message de news: ...
> > On Wed, 17 Dec 2003 18:18:33 GMT, Gene Wirchenko
> > <> wrote:
> >
> > > Is the following guaranteed safe?
> >
> > Oops! I forgot to
> > #include <iostream>
> >
> > > void InitInt(int & SomeInt)
> > > {
> > > SomeInt=3;
> > > return;
> > > }
> > >
> > > int main()
> > > {
> > > int MainInt; // not initialised!
> > > InitInt(MainInt);
> > > std::cout << MainInt << std::endl;
> > > return 0;
> > > }
> > >
> > > The intent of the function is to initialise its parm, so why
> > >bother initialising it first in main()? Unless, of course, it is not
> > >safe. Is it safe?
> >
> > Sincerely,
> >
> > Gene Wirchenko
> >
>
> sounds perfectly safe to me... nevertheless, I hardly understatnd the
point
> of this function : costs a function call and does almost nothing
> interesting... and you don't need the return in the function InitInt.
Gene probably provided the simple function just for illustration purposes.
The point is that if you pass an uninitialised object by reference, some
compilers complain (with a warning, of course), often such warning is not
necessarily founded. That's all.
Victor