RE: [Dev-C++] Use of const qualifier
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-11-01 17:16:30
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Scott Williams > Sent: Thursday, October 31, 2002 11:38 PM > To: Dev-Cpp-Users@Lists. Sourceforge. Net > Subject: [Dev-C++] Use of const qualifier > > > Hi, > > You've all been so helpful, I'm back for more . . . > > I'm curious about the use of the "const" qualifier as it applies to > prototyping function arguments. In particular, suppose I > have a function: > > double myfunc(double x, double *y) > > where myfunc uses the values of x and the array members of y > but doesn't > change them. Is there then an efficiency (speed) to be > gained by instead > declaring: > > double myfunc(const double x, const double *y)? > > Are there other advantages/disadvantages? The main benefit is type safety, that is protection from accidental errors. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |