-
December 28th, 2003, 05:00 AM
#16
Originally posted by Sam Hobbs
In other languages, when an item is passed "by reference", it is modifiable. If it is not modifiable, it is passed "by value". The modifyability of a parameter is the inherent destinction that defines the terms.
...
Again, the terms "by value" and "by reference" are intended to differentiate non-modifiable and modifiable parameters (respectively), yet in C++ many parameters that are not references are often considered to be modifiable.
No...passing by reference does not mean that the parameter is modifiable. References can allow the parameter being changed or not. At least, if the term 'reference' is used in regard to the mechanism itself instead of a description of the general mechanism of passing arguments...
-
December 28th, 2003, 05:15 AM
#17
Originally posted by Sam Hobbs
Discussions such as this do happen in this forum. That's the way it works. Sometimes the conversations don't help the person that created the thread, but if they result in something that helps others, then it usually is worthwhile.
i can dig that...=)
-- C
-
December 28th, 2003, 06:54 AM
#18
Originally posted by Sam Hobbs
Please beleive me that not everyone agrees with that. Many people would say that in:
Code:
void Func(char *String)
String is passed by reference and many people would say that String is passed by value. As a pointer, String is passed by value, but as a string, String (using non-C++ terminology) is passed by reference.
I readily believe that.
However, in your example the question is "what is String?". Is String the pointer to the character(s)? Or is String the character(s) themselves. In the first case, String is passed by value, in the second by reference. This is why I said that the terminology depends on what you refer to.
Paul is right, since references are not DEFINED to be addresses, they don't really have a value and you can't refer to them.
If you pass an argument by reference or value, there is a need for a clear definition of what we refer to. But as this very thread proves, that cannot always be read from the syntax. Maybe with a unified whitespace placement convention, but that would be the first time in history that there was such a thing.
All the buzzt
CornedBee
-
December 28th, 2003, 01:03 PM
#19
Originally posted by Andreas Masur
No...passing by reference does not mean that the parameter is modifiable. References can allow the parameter being changed or not. At least, if the term 'reference' is used in regard to the mechanism itself instead of a description of the general mechanism of passing arguments...
How many times do I need to say that I am refering to the terms "by value" and "by reference" as used in the context of other languages? How many times do I need to say that a C++ reference is different?
For example, see Argument Passing ByVal and ByRef. It says:
Passing an argument by value means the procedure cannot modify the contents of the variable element in the calling code underlying the argument. Passing by reference allows the procedure to modify the contents in the same way that the calling code itself can.
-
December 28th, 2003, 01:09 PM
#20
Originally posted by CornedBee
If you pass an argument by reference or value, there is a need for a clear definition of what we refer to.
Yes.
The only significant point I wanted to make is that in the context of C++ the terms are not defined clearly enough to be useful. In other languages, such as VB, they are clearly defined. In VB, "by value" is the ByVal keyword and "by reference" is the ByRef keyword.
-
December 29th, 2003, 01:45 PM
#21
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
|