If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Originally posted by MrViggy
Currently, you are passing the array pointer by reference, therefore the function will not be able to modify it.

It is being passed as:

Code:

short *array

Where do you see a reference? However it (the array pointer) is passed by reference in your solution.

By definition of the term "by reference" it should be modifiable if it is passed "by reference".

The terms "by reference" and "by value" can be very confusing when used for C/C++ in the manner they are used for other languages. Those terms have virtually no use in the context of the C language and a C++ reference (& operator) is different from a reference for other languages.

Of course, you probably meant to say that the array pointer was being passed "by value", and if so, then that might be an example of how confusing the terminology is when it is used for C/C++.

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 think I had a similar discussion a while back (I think over a year ago) with Paul McKenzie.

Everything in C is passed by value. When a parameter is char *, the type is pointer to char. Since a pointer is an integral value (and it must be an integral value), it is no different than passing an int, double, float, etc. Now in the called function what you do with the value is another issue. If it's a pointer, the value can be dereferenced.

In C++, you have a pass-by-reference in which reference types are used. A reference is not a true "value", in that it is theoretically dimensionless -- it has no "size" (you can get the sizeof() what is being referred, but you can't get the sizeof() a reference), plus many other things that you can do with true value types that disqualifies references.

Basically, a reference is a C++ invention, and any compiler can come up with any way it wants when representing what a reference really is. For most compiler's, a reference does boil down to a pointer of some sort, but it isn't a hard, fast, rule. This is why it is legitimate to state that pass-by-reference and pass-by-value are two different and well-defined concepts when referring to C and C++. For other languages, then it may mean different things.

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 think I had a similar discussion a while back (I think over a year ago) with Paul McKenzie.

whats the point of picking things to death? why make such a big fuss over simple terminology that you learn in programming 101?

Originally posted by clockworks
i don't see how or >why< the above c++ terminology should be debated.

Then ignore this thread. I assume you don't look at every post in every thread. If you are getting email notifications of replies to this thread, you can usubscribe to getting email notifications of replies to this thread.

For those of us that have seen thousands of posts in this forum, we know how important it is to be accurate in terminology. You might not get help when you ask for it if you are not clear and accurate about what you are asking.

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.

In C++, beginners can get confused when something is passed as a "LPSTR". It is not a reference, right? Therefore the parameter is passed "by value" and not modifiable, right? Of course experienced C++ programmers understand, but this could be confusing for beginners.

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. When someone understands C++ well enough to understand that something is modifiable only if the parameter is a pointer to it, then they understand well enough that we don't need to use the terms "by value" and "by reference".

Originally posted by Sam Hobbs
Then ignore this thread. I assume you don't look at every post in every thread. If you are getting email notifications of replies to this thread, you can usubscribe to getting email notifications of replies to this thread.

For those of us that have seen thousands of posts in this forum, we know how important it is to be accurate in terminology. You might not get help when you ask for it if you are not clear and accurate about what you are asking.

but the member who posted this thread could have got a very simply answer to his question. instead, he gets bombarded with discussion of ultra-technicalities by the seasoned veterans.

i think my post outlined exactly what he needed to know as a novice, without being confused with discussions about "computer philosopy" instead of "computer science".

i agree with you that when you post questions, you must be as articulate as possible or you will receive no help or wrong help. but this discussion of articulation, i believe, is more confusing than helpful...especially for a newbie.

Originally posted by clockworks
but the member who posted this thread could have got a very simply answer to his question. instead, he gets bombarded with discussion of ultra-technicalities by the seasoned veterans.

Note that the first reply above says "you either need to pass the array pointer by value, or pass in a pointer to the pointer to the array". However passing an array pointer by value is not what is needed; if the terminology being discussed here is used, then it would be that the array pointer needs to be passed by reference. The sample caaled "Pass by value" is good, but there is no need for the pass "by value" terminology, and instead of helping, it is confusing.

Originally posted by clockworks
but this discussion of articulation, i believe, is more confusing than helpful...especially for a newbie.

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.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.