|
-
Jun 10th, 2004, 06:40 PM
#1
Thread Starter
Fanatic Member
Why do we have const arguments?
Why do we declare some arguments as constant? Is it because we do not expect the value of those constant arguments to change in the function?
-
Jun 10th, 2004, 08:25 PM
#2
Hyperactive Member
Re: Why do we have const arguments?
Originally posted by Sathyaish
Why do we declare some arguments as constant? Is it because we do not expect the value of those constant arguments to change in the function?
You declare arguments constant when you don't want to be able to modify the types/objects being sent through the argument. For example, sometimes you wish to pass an object into a function by reference using a pointer/reference and you just want to get data from this object and not actually change it. This is often the case when you overload operators. It's more or less a safety precaution.
C.O.M.R.E.A.K.: Cybernetic Obedient Machine Responsible for Exploration and Accurate Killing
-
Jun 11th, 2004, 02:54 AM
#3
It also allows the compiler more leeway.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 14th, 2004, 09:33 AM
#4
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|