|
Boost : |
From: Bo Persson (bop2_at_[hidden])
Date: 2003-04-23 13:32:22
"Justin M. Lewis" <boost_at_[hidden]> skrev i meddelandet
news:00bf01c309b6$05a170f0$0500000a_at_justinslaptop...
> Not entirely, passing a pointer doesn't tell you that the parameter will
> change, it just tells you that it might, it still leaves you in the
position
> of having to track down the function and check it. But outside of that,
if
> you're like me, at this point you prefer references to pointers, whenever
> possible.
The obvious solution is of course to name the function so that you can tell
what is does! :-)
A function returning a single value, should really RETURN the value and not
update a parameter:
y = year_of_first_marriage();
Having a function lying about its purpose should be caught at its
definition, not at each call of the function:
void will_never_change_any_parameters_honest(int& x) { x = 7; }
is easy to catch early. :-)
Bo Persson
bop2_at_[hidden]
>
> ----- Original Message -----
> From: "Vincent Finn" <vincent.finn_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Wednesday, April 23, 2003 2:09 AM
> Subject: [boost] Re: class proposal
>
>
> > >
> > > void func(int &x){x = 1977;};
> > >
> > > void blah()
> > > {
> > > int y=0;
> > > func(y);
> > > func2(y);
> > > printf("%d\n", y);
> > > }
> > >
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk