const and call by value parameters
- From: "Mark" <swozz_@xxxxxxxxxxx>
- Date: Thu, 17 Nov 2005 11:51:57 -0000
I have a function
void myobject::g (double d)
{
dval = d;
}
Now function g() doesn't modify it's local copy of d in any way, therefore
it should be declared as
void myobject::g (const double d) {}
The thing is, I find that the vast majority of my call by value parameters
aren't reused within their functions, therefore I find that I have an awful
lot of function parameters using the const modifier.
When I look at other code, in books or in libraries, you don't tend to see
const littered throughout the code, even in functions that don't modify
their value parameters.
Am I missing something here?
--
Best regards
Mark
.
- Follow-Ups:
- Re: const and call by value parameters
- From: Doug Harrison [MVP]
- Re: const and call by value parameters
- From: David Wilkinson
- RE: const and call by value parameters
- From: Arman Sahakyan
- Re: const and call by value parameters
- Prev by Date: Re: Unhandled exception - caused by not deleting vector?
- Next by Date: Re: The use of CONST and '&' as argument parameter
- Previous by thread: Re: Unhandled exception - caused by not deleting vector?
- Next by thread: RE: const and call by value parameters
- Index(es):
Relevant Pages
|